Files
RedBear-OS/local/recipes/dev/libclc/source/lld/MachO/Dwarf.cpp
T
vasilito cb424d7448 build: static patch-sanity linter (shift-left the malformed-patch class)
verify-patch-sanity.py validates every active recipe .patch has internally-
consistent hunk line counts — catching the 'malformed patch at line N' failure
at commit/CI/preflight time instead of hours into a cook. This cycle hit that
class three times (qtwaylandscanner, sddm, xwayland), each only discovered when
cookbook tried to apply the patch.

Running it across the repo found 29 latent malformed patches (validated against
GNU patch: e.g. relibc/P3-sysv-ipc reproduces 'malformed patch at line 22').
They were harmless only because they sit in vendored recipes (baked, not re-
applied) — but would fail on any version-bump re-derivation. --fix recounts the
hunk headers (body untouched) and repaired all 29.

Wired into build-preflight.sh (Phase 1.0D) and redbear-ci.yml, with a unit test
(test-patch-sanity.sh). Skips archived/legacy trees and unvalidatable formats
(empty placeholders, bare-@@ git hunks).
2026-08-01 05:13:02 +03:00

46 lines
1.7 KiB
C++

//===- DWARF.cpp ----------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "Dwarf.h"
#include "InputFiles.h"
#include "InputSection.h"
#include "OutputSegment.h"
#include <memory>
using namespace lld;
using namespace lld::macho;
using namespace llvm;
std::unique_ptr<DwarfObject> DwarfObject::create(ObjFile *obj) {
auto dObj = std::make_unique<DwarfObject>();
bool hasDwarfInfo = false;
// LLD only needs to extract the source file path and line numbers from the
// debug info, so we initialize DwarfObject with just the sections necessary
// to get that path. The debugger will locate the debug info via the object
// file paths that we emit in our STABS symbols, so we don't need to process &
// emit them ourselves.
for (const InputSection *isec : obj->debugSections) {
if (StringRef *s =
StringSwitch<StringRef *>(isec->getName())
.Case(section_names::debugInfo, &dObj->infoSection.Data)
.Case(section_names::debugLine, &dObj->lineSection.Data)
.Case(section_names::debugStrOffs, &dObj->strOffsSection.Data)
.Case(section_names::debugAbbrev, &dObj->abbrevSection)
.Case(section_names::debugStr, &dObj->strSection)
.Default(nullptr)) {
*s = toStringRef(isec->data);
hasDwarfInfo = true;
}
}
if (hasDwarfInfo)
return dObj;
return nullptr;
}