aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/llvm12/tools
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.ru>2022-02-10 16:44:30 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:44:30 +0300
commit2598ef1d0aee359b4b6d5fdd1758916d5907d04f (patch)
tree012bb94d777798f1f56ac1cec429509766d05181 /contrib/libs/llvm12/tools
parent6751af0b0c1b952fede40b19b71da8025b5d8bcf (diff)
downloadydb-2598ef1d0aee359b4b6d5fdd1758916d5907d04f.tar.gz
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/llvm12/tools')
-rw-r--r--contrib/libs/llvm12/tools/dsymutil/BinaryHolder.cpp44
-rw-r--r--contrib/libs/llvm12/tools/dsymutil/BinaryHolder.h2
-rw-r--r--contrib/libs/llvm12/tools/dsymutil/DebugMap.cpp2
-rw-r--r--contrib/libs/llvm12/tools/dsymutil/DwarfLinkerForBinary.cpp256
-rw-r--r--contrib/libs/llvm12/tools/dsymutil/DwarfLinkerForBinary.h74
-rw-r--r--contrib/libs/llvm12/tools/dsymutil/MachODebugMapParser.cpp2
-rw-r--r--contrib/libs/llvm12/tools/dsymutil/MachOUtils.cpp126
-rw-r--r--contrib/libs/llvm12/tools/dsymutil/SymbolMap.cpp2
-rw-r--r--contrib/libs/llvm12/tools/dsymutil/dsymutil.cpp4
-rw-r--r--contrib/libs/llvm12/tools/dsymutil/ya.make124
-rw-r--r--contrib/libs/llvm12/tools/llvm-cvtres/llvm-cvtres.cpp4
-rw-r--r--contrib/libs/llvm12/tools/llvm-cvtres/ya.make32
-rw-r--r--contrib/libs/llvm12/tools/llvm-lipo/llvm-lipo.cpp260
-rw-r--r--contrib/libs/llvm12/tools/llvm-lipo/ya.make92
-rw-r--r--contrib/libs/llvm12/tools/llvm-ml/Opts.td220
-rw-r--r--contrib/libs/llvm12/tools/llvm-ml/llvm-ml.cpp400
-rw-r--r--contrib/libs/llvm12/tools/llvm-ml/ya.make70
-rw-r--r--contrib/libs/llvm12/tools/llvm-mt/llvm-mt.cpp4
-rw-r--r--contrib/libs/llvm12/tools/llvm-mt/ya.make16
-rw-r--r--contrib/libs/llvm12/tools/llvm-objcopy/BitcodeStripOpts.td48
-rw-r--r--contrib/libs/llvm12/tools/llvm-objcopy/COFF/COFFObjcopy.cpp46
-rw-r--r--contrib/libs/llvm12/tools/llvm-objcopy/COFF/Object.cpp64
-rw-r--r--contrib/libs/llvm12/tools/llvm-objcopy/COFF/Object.h4
-rw-r--r--contrib/libs/llvm12/tools/llvm-objcopy/CopyConfig.cpp238
-rw-r--r--contrib/libs/llvm12/tools/llvm-objcopy/CopyConfig.h18
-rw-r--r--contrib/libs/llvm12/tools/llvm-objcopy/ELF/ELFObjcopy.cpp184
-rw-r--r--contrib/libs/llvm12/tools/llvm-objcopy/ELF/Object.cpp1192
-rw-r--r--contrib/libs/llvm12/tools/llvm-objcopy/ELF/Object.h276
-rw-r--r--contrib/libs/llvm12/tools/llvm-objcopy/InstallNameToolOpts.td20
-rw-r--r--contrib/libs/llvm12/tools/llvm-objcopy/MachO/MachOLayoutBuilder.cpp24
-rw-r--r--contrib/libs/llvm12/tools/llvm-objcopy/MachO/MachOLayoutBuilder.h12
-rw-r--r--contrib/libs/llvm12/tools/llvm-objcopy/MachO/MachOObjcopy.cpp242
-rw-r--r--contrib/libs/llvm12/tools/llvm-objcopy/MachO/MachOObjcopy.h8
-rw-r--r--contrib/libs/llvm12/tools/llvm-objcopy/MachO/MachOReader.cpp60
-rw-r--r--contrib/libs/llvm12/tools/llvm-objcopy/MachO/MachOReader.h6
-rw-r--r--contrib/libs/llvm12/tools/llvm-objcopy/MachO/MachOWriter.cpp26
-rw-r--r--contrib/libs/llvm12/tools/llvm-objcopy/MachO/Object.cpp94
-rw-r--r--contrib/libs/llvm12/tools/llvm-objcopy/MachO/Object.h24
-rw-r--r--contrib/libs/llvm12/tools/llvm-objcopy/llvm-objcopy.cpp102
-rw-r--r--contrib/libs/llvm12/tools/llvm-objcopy/llvm-objcopy.h26
-rw-r--r--contrib/libs/llvm12/tools/llvm-objcopy/wasm/Object.cpp2
-rw-r--r--contrib/libs/llvm12/tools/llvm-objcopy/ya.make32
-rw-r--r--contrib/libs/llvm12/tools/llvm-rc/Opts.td50
-rw-r--r--contrib/libs/llvm12/tools/llvm-rc/ResourceFileWriter.cpp24
-rw-r--r--contrib/libs/llvm12/tools/llvm-rc/ResourceScriptParser.cpp6
-rw-r--r--contrib/libs/llvm12/tools/llvm-rc/ResourceScriptStmt.h6
-rw-r--r--contrib/libs/llvm12/tools/llvm-rc/llvm-rc.cpp26
-rw-r--r--contrib/libs/llvm12/tools/llvm-rc/ya.make14
-rw-r--r--contrib/libs/llvm12/tools/llvm-symbolizer/Opts.td142
-rw-r--r--contrib/libs/llvm12/tools/llvm-symbolizer/llvm-symbolizer.cpp368
-rw-r--r--contrib/libs/llvm12/tools/llvm-symbolizer/ya.make42
51 files changed, 2580 insertions, 2580 deletions
diff --git a/contrib/libs/llvm12/tools/dsymutil/BinaryHolder.cpp b/contrib/libs/llvm12/tools/dsymutil/BinaryHolder.cpp
index f83521346c..3b2e1d462c 100644
--- a/contrib/libs/llvm12/tools/dsymutil/BinaryHolder.cpp
+++ b/contrib/libs/llvm12/tools/dsymutil/BinaryHolder.cpp
@@ -87,8 +87,8 @@ Error BinaryHolder::ArchiveEntry::load(IntrusiveRefCntPtr<vfs::FileSystem> VFS,
}
Error BinaryHolder::ObjectEntry::load(IntrusiveRefCntPtr<vfs::FileSystem> VFS,
- StringRef Filename, TimestampTy Timestamp,
- bool Verbose) {
+ StringRef Filename, TimestampTy Timestamp,
+ bool Verbose) {
// Try to load regular binary and force it to be memory mapped.
auto ErrOrBuff = (Filename == "-")
? MemoryBuffer::getSTDIN()
@@ -96,18 +96,18 @@ Error BinaryHolder::ObjectEntry::load(IntrusiveRefCntPtr<vfs::FileSystem> VFS,
if (auto Err = ErrOrBuff.getError())
return errorCodeToError(Err);
- if (Filename != "-" && Timestamp != sys::TimePoint<>()) {
- llvm::ErrorOr<vfs::Status> Stat = VFS->status(Filename);
- if (!Stat)
- return errorCodeToError(Stat.getError());
- if (Timestamp != std::chrono::time_point_cast<std::chrono::seconds>(
- Stat->getLastModificationTime()))
- WithColor::warning() << Filename
- << ": timestamp mismatch between object file ("
- << Stat->getLastModificationTime()
- << ") and debug map (" << Timestamp << ")\n";
- }
-
+ if (Filename != "-" && Timestamp != sys::TimePoint<>()) {
+ llvm::ErrorOr<vfs::Status> Stat = VFS->status(Filename);
+ if (!Stat)
+ return errorCodeToError(Stat.getError());
+ if (Timestamp != std::chrono::time_point_cast<std::chrono::seconds>(
+ Stat->getLastModificationTime()))
+ WithColor::warning() << Filename
+ << ": timestamp mismatch between object file ("
+ << Stat->getLastModificationTime()
+ << ") and debug map (" << Timestamp << ")\n";
+ }
+
MemBuffer = std::move(*ErrOrBuff);
if (Verbose)
@@ -193,14 +193,14 @@ BinaryHolder::ArchiveEntry::getObjectEntry(StringRef Filename,
return ModTimeOrErr.takeError();
if (Timestamp != sys::TimePoint<>() &&
- Timestamp != std::chrono::time_point_cast<std::chrono::seconds>(
- ModTimeOrErr.get())) {
+ Timestamp != std::chrono::time_point_cast<std::chrono::seconds>(
+ ModTimeOrErr.get())) {
if (Verbose)
- WithColor::warning()
- << *NameOrErr
- << ": timestamp mismatch between archive member ("
- << ModTimeOrErr.get() << ") and debug map (" << Timestamp
- << ")\n";
+ WithColor::warning()
+ << *NameOrErr
+ << ": timestamp mismatch between archive member ("
+ << ModTimeOrErr.get() << ") and debug map (" << Timestamp
+ << ")\n";
continue;
}
@@ -264,7 +264,7 @@ BinaryHolder::getObjectEntry(StringRef Filename, TimestampTy Timestamp) {
std::lock_guard<std::mutex> Lock(ObjectCacheMutex);
if (!ObjectCache.count(Filename)) {
ObjectEntry &OE = ObjectCache[Filename];
- auto Err = OE.load(VFS, Filename, Timestamp, Verbose);
+ auto Err = OE.load(VFS, Filename, Timestamp, Verbose);
if (Err) {
ObjectCache.erase(Filename);
return std::move(Err);
diff --git a/contrib/libs/llvm12/tools/dsymutil/BinaryHolder.h b/contrib/libs/llvm12/tools/dsymutil/BinaryHolder.h
index 5e81fe4b93..dff33a752f 100644
--- a/contrib/libs/llvm12/tools/dsymutil/BinaryHolder.h
+++ b/contrib/libs/llvm12/tools/dsymutil/BinaryHolder.h
@@ -58,7 +58,7 @@ public:
public:
/// Load the given object binary in memory.
Error load(IntrusiveRefCntPtr<vfs::FileSystem> VFS, StringRef Filename,
- TimestampTy Timestamp, bool Verbose = false);
+ TimestampTy Timestamp, bool Verbose = false);
/// Access all owned ObjectFiles.
std::vector<const object::ObjectFile *> getObjects() const;
diff --git a/contrib/libs/llvm12/tools/dsymutil/DebugMap.cpp b/contrib/libs/llvm12/tools/dsymutil/DebugMap.cpp
index 605c1317b9..a1e4536dfd 100644
--- a/contrib/libs/llvm12/tools/dsymutil/DebugMap.cpp
+++ b/contrib/libs/llvm12/tools/dsymutil/DebugMap.cpp
@@ -60,7 +60,7 @@ void DebugMapObject::print(raw_ostream &OS) const {
using Entry = std::pair<StringRef, SymbolMapping>;
std::vector<Entry> Entries;
Entries.reserve(Symbols.getNumItems());
- for (const auto &Sym : Symbols)
+ for (const auto &Sym : Symbols)
Entries.push_back(std::make_pair(Sym.getKey(), Sym.getValue()));
llvm::sort(Entries, [](const Entry &LHS, const Entry &RHS) {
return LHS.first < RHS.first;
diff --git a/contrib/libs/llvm12/tools/dsymutil/DwarfLinkerForBinary.cpp b/contrib/libs/llvm12/tools/dsymutil/DwarfLinkerForBinary.cpp
index 29408e7c49..28aa8496ff 100644
--- a/contrib/libs/llvm12/tools/dsymutil/DwarfLinkerForBinary.cpp
+++ b/contrib/libs/llvm12/tools/dsymutil/DwarfLinkerForBinary.cpp
@@ -262,7 +262,7 @@ static Error emitRemarks(const LinkOptions &Options, StringRef BinaryPath,
return Error::success();
}
-ErrorOr<DWARFFile &>
+ErrorOr<DWARFFile &>
DwarfLinkerForBinary::loadObject(const DebugMapObject &Obj,
const DebugMap &DebugMap,
remarks::RemarkLinker &RL) {
@@ -274,7 +274,7 @@ DwarfLinkerForBinary::loadObject(const DebugMapObject &Obj,
AddressMapForLinking.push_back(
std::make_unique<AddressManager>(*this, *ErrorOrObj, Obj));
- ObjectsForLinking.push_back(std::make_unique<DWARFFile>(
+ ObjectsForLinking.push_back(std::make_unique<DWARFFile>(
Obj.getObjectFilename(), ContextForLinking.back().get(),
AddressMapForLinking.back().get(),
Obj.empty() ? Obj.getWarnings() : EmptyWarnings));
@@ -334,7 +334,7 @@ bool DwarfLinkerForBinary::link(const DebugMap &Map) {
});
GeneralLinker.setObjFileLoader(
[&DebugMap, &RL, this](StringRef ContainerName,
- StringRef Path) -> ErrorOr<DWARFFile &> {
+ StringRef Path) -> ErrorOr<DWARFFile &> {
auto &Obj = DebugMap.addDebugMapObject(
Path, sys::TimePoint<std::chrono::seconds>(), MachO::N_OSO);
@@ -412,10 +412,10 @@ bool DwarfLinkerForBinary::link(const DebugMap &Map) {
Stat.getLastModificationTime());
if (ModificationTime != Obj->getTimestamp()) {
// Not using the helper here as we can easily stream TimePoint<>.
- WithColor::warning()
- << File << ": timestamp mismatch between swift interface file ("
- << sys::TimePoint<>(Obj->getTimestamp()) << ") and debug map ("
- << sys::TimePoint<>(Obj->getTimestamp()) << ")\n";
+ WithColor::warning()
+ << File << ": timestamp mismatch between swift interface file ("
+ << sys::TimePoint<>(Obj->getTimestamp()) << ") and debug map ("
+ << sys::TimePoint<>(Obj->getTimestamp()) << ")\n";
continue;
}
}
@@ -430,7 +430,7 @@ bool DwarfLinkerForBinary::link(const DebugMap &Map) {
if (auto ErrorOrObj = loadObject(*Obj, Map, RL))
GeneralLinker.addObjectFile(*ErrorOrObj);
else {
- ObjectsForLinking.push_back(std::make_unique<DWARFFile>(
+ ObjectsForLinking.push_back(std::make_unique<DWARFFile>(
Obj->getObjectFilename(), nullptr, nullptr,
Obj->empty() ? Obj->getWarnings() : EmptyWarnings));
GeneralLinker.addObjectFile(*ObjectsForLinking.back());
@@ -489,7 +489,7 @@ static bool isMachOPairedReloc(uint64_t RelocType, uint64_t Arch) {
/// ValidRelocs array.
void DwarfLinkerForBinary::AddressManager::findValidRelocsMachO(
const object::SectionRef &Section, const object::MachOObjectFile &Obj,
- const DebugMapObject &DMO, std::vector<ValidReloc> &ValidRelocs) {
+ const DebugMapObject &DMO, std::vector<ValidReloc> &ValidRelocs) {
Expected<StringRef> ContentsOrErr = Section.getContents();
if (!ContentsOrErr) {
consumeError(ContentsOrErr.takeError());
@@ -511,8 +511,8 @@ void DwarfLinkerForBinary::AddressManager::findValidRelocsMachO(
if (isMachOPairedReloc(Obj.getAnyRelocationType(MachOReloc),
Obj.getArch())) {
SkipNext = true;
- Linker.reportWarning("unsupported relocation in " + *Section.getName() +
- " section.",
+ Linker.reportWarning("unsupported relocation in " + *Section.getName() +
+ " section.",
DMO.getObjectFilename());
continue;
}
@@ -520,8 +520,8 @@ void DwarfLinkerForBinary::AddressManager::findValidRelocsMachO(
unsigned RelocSize = 1 << Obj.getAnyRelocationLength(MachOReloc);
uint64_t Offset64 = Reloc.getOffset();
if ((RelocSize != 4 && RelocSize != 8)) {
- Linker.reportWarning("unsupported relocation in " + *Section.getName() +
- " section.",
+ Linker.reportWarning("unsupported relocation in " + *Section.getName() +
+ " section.",
DMO.getObjectFilename());
continue;
}
@@ -566,33 +566,33 @@ void DwarfLinkerForBinary::AddressManager::findValidRelocsMachO(
/// appropriate handler depending on the object file format.
bool DwarfLinkerForBinary::AddressManager::findValidRelocs(
const object::SectionRef &Section, const object::ObjectFile &Obj,
- const DebugMapObject &DMO, std::vector<ValidReloc> &Relocs) {
+ const DebugMapObject &DMO, std::vector<ValidReloc> &Relocs) {
// Dispatch to the right handler depending on the file type.
if (auto *MachOObj = dyn_cast<object::MachOObjectFile>(&Obj))
- findValidRelocsMachO(Section, *MachOObj, DMO, Relocs);
+ findValidRelocsMachO(Section, *MachOObj, DMO, Relocs);
else
Linker.reportWarning(Twine("unsupported object file type: ") +
Obj.getFileName(),
DMO.getObjectFilename());
- if (Relocs.empty())
+ if (Relocs.empty())
return false;
// Sort the relocations by offset. We will walk the DIEs linearly in
// the file, this allows us to just keep an index in the relocation
// array that we advance during our walk, rather than resorting to
// some associative container. See DwarfLinkerForBinary::NextValidReloc.
- llvm::sort(Relocs);
+ llvm::sort(Relocs);
return true;
}
-/// Look for relocations in the debug_info and debug_addr section that match
-/// entries in the debug map. These relocations will drive the Dwarf link by
-/// indicating which DIEs refer to symbols present in the linked binary.
+/// Look for relocations in the debug_info and debug_addr section that match
+/// entries in the debug map. These relocations will drive the Dwarf link by
+/// indicating which DIEs refer to symbols present in the linked binary.
/// \returns whether there are any valid relocations in the debug info.
-bool DwarfLinkerForBinary::AddressManager::findValidRelocsInDebugSections(
+bool DwarfLinkerForBinary::AddressManager::findValidRelocsInDebugSections(
const object::ObjectFile &Obj, const DebugMapObject &DMO) {
// Find the debug_info section.
- bool FoundValidRelocs = false;
+ bool FoundValidRelocs = false;
for (const object::SectionRef &Section : Obj.sections()) {
StringRef SectionName;
if (Expected<StringRef> NameOrErr = Section.getName())
@@ -601,44 +601,44 @@ bool DwarfLinkerForBinary::AddressManager::findValidRelocsInDebugSections(
consumeError(NameOrErr.takeError());
SectionName = SectionName.substr(SectionName.find_first_not_of("._"));
- if (SectionName == "debug_info")
- FoundValidRelocs |=
- findValidRelocs(Section, Obj, DMO, ValidDebugInfoRelocs);
- if (SectionName == "debug_addr")
- FoundValidRelocs |=
- findValidRelocs(Section, Obj, DMO, ValidDebugAddrRelocs);
+ if (SectionName == "debug_info")
+ FoundValidRelocs |=
+ findValidRelocs(Section, Obj, DMO, ValidDebugInfoRelocs);
+ if (SectionName == "debug_addr")
+ FoundValidRelocs |=
+ findValidRelocs(Section, Obj, DMO, ValidDebugAddrRelocs);
}
- return FoundValidRelocs;
+ return FoundValidRelocs;
}
-bool DwarfLinkerForBinary::AddressManager::hasValidDebugAddrRelocationAt(
- uint64_t Offset) {
- auto It = std::lower_bound(ValidDebugAddrRelocs.begin(),
- ValidDebugAddrRelocs.end(), Offset);
- return It != ValidDebugAddrRelocs.end();
-}
-
-bool DwarfLinkerForBinary::AddressManager::hasValidDebugInfoRelocationAt(
+bool DwarfLinkerForBinary::AddressManager::hasValidDebugAddrRelocationAt(
+ uint64_t Offset) {
+ auto It = std::lower_bound(ValidDebugAddrRelocs.begin(),
+ ValidDebugAddrRelocs.end(), Offset);
+ return It != ValidDebugAddrRelocs.end();
+}
+
+bool DwarfLinkerForBinary::AddressManager::hasValidDebugInfoRelocationAt(
uint64_t StartOffset, uint64_t EndOffset, CompileUnit::DIEInfo &Info) {
assert(NextValidReloc == 0 ||
- StartOffset > ValidDebugInfoRelocs[NextValidReloc - 1].Offset);
- if (NextValidReloc >= ValidDebugInfoRelocs.size())
+ StartOffset > ValidDebugInfoRelocs[NextValidReloc - 1].Offset);
+ if (NextValidReloc >= ValidDebugInfoRelocs.size())
return false;
- uint64_t RelocOffset = ValidDebugInfoRelocs[NextValidReloc].Offset;
+ uint64_t RelocOffset = ValidDebugInfoRelocs[NextValidReloc].Offset;
// We might need to skip some relocs that we didn't consider. For
// example the high_pc of a discarded DIE might contain a reloc that
// is in the list because it actually corresponds to the start of a
// function that is in the debug map.
- while (RelocOffset < StartOffset &&
- NextValidReloc < ValidDebugInfoRelocs.size() - 1)
- RelocOffset = ValidDebugInfoRelocs[++NextValidReloc].Offset;
+ while (RelocOffset < StartOffset &&
+ NextValidReloc < ValidDebugInfoRelocs.size() - 1)
+ RelocOffset = ValidDebugInfoRelocs[++NextValidReloc].Offset;
if (RelocOffset < StartOffset || RelocOffset >= EndOffset)
return false;
- const auto &ValidReloc = ValidDebugInfoRelocs[NextValidReloc++];
+ const auto &ValidReloc = ValidDebugInfoRelocs[NextValidReloc++];
const auto &Mapping = ValidReloc.Mapping->getValue();
const uint64_t BinaryAddress = Mapping.BinaryAddress;
const uint64_t ObjectAddress = Mapping.ObjectAddress
@@ -657,71 +657,71 @@ bool DwarfLinkerForBinary::AddressManager::hasValidDebugInfoRelocationAt(
return true;
}
-/// Get the starting and ending (exclusive) offset for the
-/// attribute with index \p Idx descibed by \p Abbrev. \p Offset is
-/// supposed to point to the position of the first attribute described
-/// by \p Abbrev.
-/// \return [StartOffset, EndOffset) as a pair.
-static std::pair<uint64_t, uint64_t>
-getAttributeOffsets(const DWARFAbbreviationDeclaration *Abbrev, unsigned Idx,
- uint64_t Offset, const DWARFUnit &Unit) {
- DataExtractor Data = Unit.getDebugInfoExtractor();
-
- for (unsigned I = 0; I < Idx; ++I)
- DWARFFormValue::skipValue(Abbrev->getFormByIndex(I), Data, &Offset,
- Unit.getFormParams());
-
- uint64_t End = Offset;
- DWARFFormValue::skipValue(Abbrev->getFormByIndex(Idx), Data, &End,
- Unit.getFormParams());
-
- return std::make_pair(Offset, End);
-}
-
-bool DwarfLinkerForBinary::AddressManager::hasLiveMemoryLocation(
- const DWARFDie &DIE, CompileUnit::DIEInfo &MyInfo) {
- const auto *Abbrev = DIE.getAbbreviationDeclarationPtr();
-
- Optional<uint32_t> LocationIdx =
- Abbrev->findAttributeIndex(dwarf::DW_AT_location);
- if (!LocationIdx)
- return false;
-
- uint64_t Offset = DIE.getOffset() + getULEB128Size(Abbrev->getCode());
- uint64_t LocationOffset, LocationEndOffset;
- std::tie(LocationOffset, LocationEndOffset) =
- getAttributeOffsets(Abbrev, *LocationIdx, Offset, *DIE.getDwarfUnit());
-
- // FIXME: Support relocations debug_addr.
- return hasValidDebugInfoRelocationAt(LocationOffset, LocationEndOffset,
- MyInfo);
-}
-
-bool DwarfLinkerForBinary::AddressManager::hasLiveAddressRange(
- const DWARFDie &DIE, CompileUnit::DIEInfo &MyInfo) {
- const auto *Abbrev = DIE.getAbbreviationDeclarationPtr();
-
- Optional<uint32_t> LowPcIdx = Abbrev->findAttributeIndex(dwarf::DW_AT_low_pc);
- if (!LowPcIdx)
- return false;
-
- dwarf::Form Form = Abbrev->getFormByIndex(*LowPcIdx);
-
- if (Form == dwarf::DW_FORM_addr) {
- uint64_t Offset = DIE.getOffset() + getULEB128Size(Abbrev->getCode());
- uint64_t LowPcOffset, LowPcEndOffset;
- std::tie(LowPcOffset, LowPcEndOffset) =
- getAttributeOffsets(Abbrev, *LowPcIdx, Offset, *DIE.getDwarfUnit());
- return hasValidDebugInfoRelocationAt(LowPcOffset, LowPcEndOffset, MyInfo);
- }
-
- if (Form == dwarf::DW_FORM_addrx) {
- Optional<DWARFFormValue> AddrValue = DIE.find(dwarf::DW_AT_low_pc);
- return hasValidDebugAddrRelocationAt(*AddrValue->getAsAddress());
- }
-
- return false;
-}
+/// Get the starting and ending (exclusive) offset for the
+/// attribute with index \p Idx descibed by \p Abbrev. \p Offset is
+/// supposed to point to the position of the first attribute described
+/// by \p Abbrev.
+/// \return [StartOffset, EndOffset) as a pair.
+static std::pair<uint64_t, uint64_t>
+getAttributeOffsets(const DWARFAbbreviationDeclaration *Abbrev, unsigned Idx,
+ uint64_t Offset, const DWARFUnit &Unit) {
+ DataExtractor Data = Unit.getDebugInfoExtractor();
+
+ for (unsigned I = 0; I < Idx; ++I)
+ DWARFFormValue::skipValue(Abbrev->getFormByIndex(I), Data, &Offset,
+ Unit.getFormParams());
+
+ uint64_t End = Offset;
+ DWARFFormValue::skipValue(Abbrev->getFormByIndex(Idx), Data, &End,
+ Unit.getFormParams());
+
+ return std::make_pair(Offset, End);
+}
+
+bool DwarfLinkerForBinary::AddressManager::hasLiveMemoryLocation(
+ const DWARFDie &DIE, CompileUnit::DIEInfo &MyInfo) {
+ const auto *Abbrev = DIE.getAbbreviationDeclarationPtr();
+
+ Optional<uint32_t> LocationIdx =
+ Abbrev->findAttributeIndex(dwarf::DW_AT_location);
+ if (!LocationIdx)
+ return false;
+
+ uint64_t Offset = DIE.getOffset() + getULEB128Size(Abbrev->getCode());
+ uint64_t LocationOffset, LocationEndOffset;
+ std::tie(LocationOffset, LocationEndOffset) =
+ getAttributeOffsets(Abbrev, *LocationIdx, Offset, *DIE.getDwarfUnit());
+
+ // FIXME: Support relocations debug_addr.
+ return hasValidDebugInfoRelocationAt(LocationOffset, LocationEndOffset,
+ MyInfo);
+}
+
+bool DwarfLinkerForBinary::AddressManager::hasLiveAddressRange(
+ const DWARFDie &DIE, CompileUnit::DIEInfo &MyInfo) {
+ const auto *Abbrev = DIE.getAbbreviationDeclarationPtr();
+
+ Optional<uint32_t> LowPcIdx = Abbrev->findAttributeIndex(dwarf::DW_AT_low_pc);
+ if (!LowPcIdx)
+ return false;
+
+ dwarf::Form Form = Abbrev->getFormByIndex(*LowPcIdx);
+
+ if (Form == dwarf::DW_FORM_addr) {
+ uint64_t Offset = DIE.getOffset() + getULEB128Size(Abbrev->getCode());
+ uint64_t LowPcOffset, LowPcEndOffset;
+ std::tie(LowPcOffset, LowPcEndOffset) =
+ getAttributeOffsets(Abbrev, *LowPcIdx, Offset, *DIE.getDwarfUnit());
+ return hasValidDebugInfoRelocationAt(LowPcOffset, LowPcEndOffset, MyInfo);
+ }
+
+ if (Form == dwarf::DW_FORM_addrx) {
+ Optional<DWARFFormValue> AddrValue = DIE.find(dwarf::DW_AT_low_pc);
+ return hasValidDebugAddrRelocationAt(*AddrValue->getAsAddress());
+ }
+
+ return false;
+}
/// Apply the valid relocations found by findValidRelocs() to
/// the buffer \p Data, taking into account that Data is at \p BaseOffset
/// in the debug_info section.
@@ -734,22 +734,22 @@ bool DwarfLinkerForBinary::AddressManager::applyValidRelocs(
MutableArrayRef<char> Data, uint64_t BaseOffset, bool IsLittleEndian) {
assert(areRelocationsResolved());
assert((NextValidReloc == 0 ||
- BaseOffset > ValidDebugInfoRelocs[NextValidReloc - 1].Offset) &&
+ BaseOffset > ValidDebugInfoRelocs[NextValidReloc - 1].Offset) &&
"BaseOffset should only be increasing.");
- if (NextValidReloc >= ValidDebugInfoRelocs.size())
+ if (NextValidReloc >= ValidDebugInfoRelocs.size())
return false;
// Skip relocs that haven't been applied.
- while (NextValidReloc < ValidDebugInfoRelocs.size() &&
- ValidDebugInfoRelocs[NextValidReloc].Offset < BaseOffset)
+ while (NextValidReloc < ValidDebugInfoRelocs.size() &&
+ ValidDebugInfoRelocs[NextValidReloc].Offset < BaseOffset)
++NextValidReloc;
bool Applied = false;
uint64_t EndOffset = BaseOffset + Data.size();
- while (NextValidReloc < ValidDebugInfoRelocs.size() &&
- ValidDebugInfoRelocs[NextValidReloc].Offset >= BaseOffset &&
- ValidDebugInfoRelocs[NextValidReloc].Offset < EndOffset) {
- const auto &ValidReloc = ValidDebugInfoRelocs[NextValidReloc++];
+ while (NextValidReloc < ValidDebugInfoRelocs.size() &&
+ ValidDebugInfoRelocs[NextValidReloc].Offset >= BaseOffset &&
+ ValidDebugInfoRelocs[NextValidReloc].Offset < EndOffset) {
+ const auto &ValidReloc = ValidDebugInfoRelocs[NextValidReloc++];
assert(ValidReloc.Offset - BaseOffset < Data.size());
assert(ValidReloc.Offset - BaseOffset + ValidReloc.Size <= Data.size());
char Buf[8];
@@ -767,17 +767,17 @@ bool DwarfLinkerForBinary::AddressManager::applyValidRelocs(
return Applied;
}
-llvm::Expected<uint64_t>
-DwarfLinkerForBinary::AddressManager::relocateIndexedAddr(uint64_t Offset) {
- auto It = std::lower_bound(ValidDebugAddrRelocs.begin(),
- ValidDebugAddrRelocs.end(), Offset);
- if (It == ValidDebugAddrRelocs.end())
- return createStringError(
- std::make_error_code(std::errc::invalid_argument),
- "no relocation for offset %llu in debug_addr section", Offset);
- return It->Mapping->getValue().BinaryAddress + It->Addend;
-}
-
+llvm::Expected<uint64_t>
+DwarfLinkerForBinary::AddressManager::relocateIndexedAddr(uint64_t Offset) {
+ auto It = std::lower_bound(ValidDebugAddrRelocs.begin(),
+ ValidDebugAddrRelocs.end(), Offset);
+ if (It == ValidDebugAddrRelocs.end())
+ return createStringError(
+ std::make_error_code(std::errc::invalid_argument),
+ "no relocation for offset %llu in debug_addr section", Offset);
+ return It->Mapping->getValue().BinaryAddress + It->Addend;
+}
+
bool linkDwarf(raw_fd_ostream &OutFile, BinaryHolder &BinHolder,
const DebugMap &DM, LinkOptions Options) {
DwarfLinkerForBinary Linker(OutFile, BinHolder, std::move(Options));
diff --git a/contrib/libs/llvm12/tools/dsymutil/DwarfLinkerForBinary.h b/contrib/libs/llvm12/tools/dsymutil/DwarfLinkerForBinary.h
index c6c07d689f..b17aac137f 100644
--- a/contrib/libs/llvm12/tools/dsymutil/DwarfLinkerForBinary.h
+++ b/contrib/libs/llvm12/tools/dsymutil/DwarfLinkerForBinary.h
@@ -70,17 +70,17 @@ private:
bool operator<(const ValidReloc &RHS) const {
return Offset < RHS.Offset;
}
- bool operator<(uint64_t RHS) const { return Offset < RHS; }
+ bool operator<(uint64_t RHS) const { return Offset < RHS; }
};
const DwarfLinkerForBinary &Linker;
/// The valid relocations for the current DebugMapObject.
/// This vector is sorted by relocation offset.
- /// {
- std::vector<ValidReloc> ValidDebugInfoRelocs;
- std::vector<ValidReloc> ValidDebugAddrRelocs;
- /// }
+ /// {
+ std::vector<ValidReloc> ValidDebugInfoRelocs;
+ std::vector<ValidReloc> ValidDebugAddrRelocs;
+ /// }
/// Index into ValidRelocs of the next relocation to consider. As we walk
/// the DIEs in acsending file offset and as ValidRelocs is sorted by file
@@ -94,7 +94,7 @@ private:
AddressManager(DwarfLinkerForBinary &Linker, const object::ObjectFile &Obj,
const DebugMapObject &DMO)
: Linker(Linker) {
- findValidRelocsInDebugSections(Obj, DMO);
+ findValidRelocsInDebugSections(Obj, DMO);
// Iterate over the debug map entries and put all the ones that are
// functions (because they have a size) into the Ranges map. This map is
@@ -128,56 +128,56 @@ private:
bool hasValidRelocs(bool ResetRelocsPtr = true) override {
if (ResetRelocsPtr)
NextValidReloc = 0;
- return !ValidDebugInfoRelocs.empty() || !ValidDebugAddrRelocs.empty();
+ return !ValidDebugInfoRelocs.empty() || !ValidDebugAddrRelocs.empty();
}
/// \defgroup FindValidRelocations Translate debug map into a list
/// of relevant relocations
///
/// @{
- bool findValidRelocsInDebugSections(const object::ObjectFile &Obj,
- const DebugMapObject &DMO);
+ bool findValidRelocsInDebugSections(const object::ObjectFile &Obj,
+ const DebugMapObject &DMO);
bool findValidRelocs(const object::SectionRef &Section,
const object::ObjectFile &Obj,
- const DebugMapObject &DMO,
- std::vector<ValidReloc> &ValidRelocs);
+ const DebugMapObject &DMO,
+ std::vector<ValidReloc> &ValidRelocs);
void findValidRelocsMachO(const object::SectionRef &Section,
const object::MachOObjectFile &Obj,
- const DebugMapObject &DMO,
- std::vector<ValidReloc> &ValidRelocs);
+ const DebugMapObject &DMO,
+ std::vector<ValidReloc> &ValidRelocs);
/// @}
- /// Checks that there is a relocation in the debug_addr section against a
- /// debug map entry between \p StartOffset and \p NextOffset.
- ///
- /// This function must be called with offsets in strictly ascending order
- /// because it never looks back at relocations it already 'went past'.
- /// \returns true and sets Info.InDebugMap if it is the case.
- bool hasValidDebugInfoRelocationAt(uint64_t StartOffset, uint64_t EndOffset,
- CompileUnit::DIEInfo &Info);
-
- /// Checks that there is a relocation in the debug_addr section against a
- /// debug map entry at the given offset.
- bool hasValidDebugAddrRelocationAt(uint64_t Offset);
-
- bool hasLiveMemoryLocation(const DWARFDie &DIE,
- CompileUnit::DIEInfo &Info) override;
- bool hasLiveAddressRange(const DWARFDie &DIE,
- CompileUnit::DIEInfo &Info) override;
-
+ /// Checks that there is a relocation in the debug_addr section against a
+ /// debug map entry between \p StartOffset and \p NextOffset.
+ ///
+ /// This function must be called with offsets in strictly ascending order
+ /// because it never looks back at relocations it already 'went past'.
+ /// \returns true and sets Info.InDebugMap if it is the case.
+ bool hasValidDebugInfoRelocationAt(uint64_t StartOffset, uint64_t EndOffset,
+ CompileUnit::DIEInfo &Info);
+
+ /// Checks that there is a relocation in the debug_addr section against a
+ /// debug map entry at the given offset.
+ bool hasValidDebugAddrRelocationAt(uint64_t Offset);
+
+ bool hasLiveMemoryLocation(const DWARFDie &DIE,
+ CompileUnit::DIEInfo &Info) override;
+ bool hasLiveAddressRange(const DWARFDie &DIE,
+ CompileUnit::DIEInfo &Info) override;
+
bool applyValidRelocs(MutableArrayRef<char> Data, uint64_t BaseOffset,
bool IsLittleEndian) override;
- llvm::Expected<uint64_t> relocateIndexedAddr(uint64_t Offset) override;
-
+ llvm::Expected<uint64_t> relocateIndexedAddr(uint64_t Offset) override;
+
RangesTy &getValidAddressRanges() override { return AddressRanges; }
void clear() override {
AddressRanges.clear();
- ValidDebugInfoRelocs.clear();
- ValidDebugAddrRelocs.clear();
+ ValidDebugInfoRelocs.clear();
+ ValidDebugAddrRelocs.clear();
NextValidReloc = 0;
}
};
@@ -191,7 +191,7 @@ private:
/// Attempt to load a debug object from disk.
ErrorOr<const object::ObjectFile &> loadObject(const DebugMapObject &Obj,
const Triple &triple);
- ErrorOr<DWARFFile &> loadObject(const DebugMapObject &Obj,
+ ErrorOr<DWARFFile &> loadObject(const DebugMapObject &Obj,
const DebugMap &DebugMap,
remarks::RemarkLinker &RL);
@@ -199,7 +199,7 @@ private:
BinaryHolder &BinHolder;
LinkOptions Options;
std::unique_ptr<DwarfStreamer> Streamer;
- std::vector<std::unique_ptr<DWARFFile>> ObjectsForLinking;
+ std::vector<std::unique_ptr<DWARFFile>> ObjectsForLinking;
std::vector<std::unique_ptr<DWARFContext>> ContextForLinking;
std::vector<std::unique_ptr<AddressManager>> AddressMapForLinking;
std::vector<std::string> EmptyWarnings;
diff --git a/contrib/libs/llvm12/tools/dsymutil/MachODebugMapParser.cpp b/contrib/libs/llvm12/tools/dsymutil/MachODebugMapParser.cpp
index 37848c561a..95b53c7aa0 100644
--- a/contrib/libs/llvm12/tools/dsymutil/MachODebugMapParser.cpp
+++ b/contrib/libs/llvm12/tools/dsymutil/MachODebugMapParser.cpp
@@ -564,7 +564,7 @@ void MachODebugMapParser::loadMainBinarySymbols(
continue;
}
Section = *SectionOrErr;
- if ((Section == MainBinary.section_end() || Section->isText()) && !Extern)
+ if ((Section == MainBinary.section_end() || Section->isText()) && !Extern)
continue;
uint64_t Addr = cantFail(Sym.getValue());
Expected<StringRef> NameOrErr = Sym.getName();
diff --git a/contrib/libs/llvm12/tools/dsymutil/MachOUtils.cpp b/contrib/libs/llvm12/tools/dsymutil/MachOUtils.cpp
index 943af43058..84c3f450a1 100644
--- a/contrib/libs/llvm12/tools/dsymutil/MachOUtils.cpp
+++ b/contrib/libs/llvm12/tools/dsymutil/MachOUtils.cpp
@@ -239,36 +239,36 @@ getSection(const object::MachOObjectFile &Obj,
// Transfer \a Segment from \a Obj to the output file. This calls into \a Writer
// to write these load commands directly in the output file at the current
// position.
-//
+//
// The function also tries to find a hole in the address map to fit the __DWARF
// segment of \a DwarfSegmentSize size. \a EndAddress is updated to point at the
// highest segment address.
-//
+//
// When the __LINKEDIT segment is transferred, its offset and size are set resp.
// to \a LinkeditOffset and \a LinkeditSize.
-//
-// When the eh_frame section is transferred, its offset and size are set resp.
-// to \a EHFrameOffset and \a EHFrameSize.
+//
+// When the eh_frame section is transferred, its offset and size are set resp.
+// to \a EHFrameOffset and \a EHFrameSize.
template <typename SegmentTy>
static void transferSegmentAndSections(
const object::MachOObjectFile::LoadCommandInfo &LCI, SegmentTy Segment,
const object::MachOObjectFile &Obj, MachObjectWriter &Writer,
- uint64_t LinkeditOffset, uint64_t LinkeditSize, uint64_t EHFrameOffset,
- uint64_t EHFrameSize, uint64_t DwarfSegmentSize, uint64_t &GapForDwarf,
- uint64_t &EndAddress) {
+ uint64_t LinkeditOffset, uint64_t LinkeditSize, uint64_t EHFrameOffset,
+ uint64_t EHFrameSize, uint64_t DwarfSegmentSize, uint64_t &GapForDwarf,
+ uint64_t &EndAddress) {
if (StringRef("__DWARF") == Segment.segname)
return;
- if (StringRef("__TEXT") == Segment.segname && EHFrameSize > 0) {
- Segment.fileoff = EHFrameOffset;
- Segment.filesize = EHFrameSize;
- } else if (StringRef("__LINKEDIT") == Segment.segname) {
+ if (StringRef("__TEXT") == Segment.segname && EHFrameSize > 0) {
+ Segment.fileoff = EHFrameOffset;
+ Segment.filesize = EHFrameSize;
+ } else if (StringRef("__LINKEDIT") == Segment.segname) {
Segment.fileoff = LinkeditOffset;
Segment.filesize = LinkeditSize;
// Resize vmsize by rounding to the page size.
Segment.vmsize = alignTo(LinkeditSize, 0x1000);
- } else {
- Segment.fileoff = Segment.filesize = 0;
+ } else {
+ Segment.fileoff = Segment.filesize = 0;
}
// Check if the end address of the last segment and our current
@@ -289,12 +289,12 @@ static void transferSegmentAndSections(
Writer.W.OS.write(reinterpret_cast<char *>(&Segment), sizeof(Segment));
for (unsigned i = 0; i < nsects; ++i) {
auto Sect = getSection(Obj, Segment, LCI, i);
- if (StringRef("__eh_frame") == Sect.sectname) {
- Sect.offset = EHFrameOffset;
- Sect.reloff = Sect.nreloc = 0;
- } else {
- Sect.offset = Sect.reloff = Sect.nreloc = 0;
- }
+ if (StringRef("__eh_frame") == Sect.sectname) {
+ Sect.offset = EHFrameOffset;
+ Sect.reloff = Sect.nreloc = 0;
+ } else {
+ Sect.offset = Sect.reloff = Sect.nreloc = 0;
+ }
if (Obj.isLittleEndian() != sys::IsLittleEndianHost)
MachO::swapStruct(Sect);
Writer.W.OS.write(reinterpret_cast<char *>(&Sect), sizeof(Sect));
@@ -431,27 +431,27 @@ bool generateDsymCompanion(llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS,
++NumLoadCommands;
}
- // If we have a valid eh_frame to copy, do it.
- uint64_t EHFrameSize = 0;
- StringRef EHFrameData;
- for (const object::SectionRef &Section : InputBinary.sections()) {
- Expected<StringRef> NameOrErr = Section.getName();
- if (!NameOrErr) {
- consumeError(NameOrErr.takeError());
- continue;
- }
- StringRef SectionName = *NameOrErr;
- SectionName = SectionName.substr(SectionName.find_first_not_of("._"));
- if (SectionName == "eh_frame") {
- if (Expected<StringRef> ContentsOrErr = Section.getContents()) {
- EHFrameData = *ContentsOrErr;
- EHFrameSize = Section.getSize();
- } else {
- consumeError(ContentsOrErr.takeError());
- }
- }
- }
-
+ // If we have a valid eh_frame to copy, do it.
+ uint64_t EHFrameSize = 0;
+ StringRef EHFrameData;
+ for (const object::SectionRef &Section : InputBinary.sections()) {
+ Expected<StringRef> NameOrErr = Section.getName();
+ if (!NameOrErr) {
+ consumeError(NameOrErr.takeError());
+ continue;
+ }
+ StringRef SectionName = *NameOrErr;
+ SectionName = SectionName.substr(SectionName.find_first_not_of("._"));
+ if (SectionName == "eh_frame") {
+ if (Expected<StringRef> ContentsOrErr = Section.getContents()) {
+ EHFrameData = *ContentsOrErr;
+ EHFrameSize = Section.getSize();
+ } else {
+ consumeError(ContentsOrErr.takeError());
+ }
+ }
+ }
+
unsigned HeaderSize =
Is64Bit ? sizeof(MachO::mach_header_64) : sizeof(MachO::mach_header);
// We will copy every segment that isn't __DWARF.
@@ -531,10 +531,10 @@ bool generateDsymCompanion(llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS,
Writer.writeSymtabLoadCommand(SymtabStart, NumSyms, StringStart,
NewStringsSize);
- uint64_t EHFrameStart = StringStart + NewStringsSize;
- EHFrameStart = alignTo(EHFrameStart, 0x1000);
-
- uint64_t DwarfSegmentStart = EHFrameStart + EHFrameSize;
+ uint64_t EHFrameStart = StringStart + NewStringsSize;
+ EHFrameStart = alignTo(EHFrameStart, 0x1000);
+
+ uint64_t DwarfSegmentStart = EHFrameStart + EHFrameSize;
DwarfSegmentStart = alignTo(DwarfSegmentStart, 0x1000);
// Write the load commands for the segments and sections we 'import' from
@@ -543,15 +543,15 @@ bool generateDsymCompanion(llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS,
uint64_t GapForDwarf = UINT64_MAX;
for (auto &LCI : InputBinary.load_commands()) {
if (LCI.C.cmd == MachO::LC_SEGMENT)
- transferSegmentAndSections(
- LCI, InputBinary.getSegmentLoadCommand(LCI), InputBinary, Writer,
- SymtabStart, StringStart + NewStringsSize - SymtabStart, EHFrameStart,
- EHFrameSize, DwarfSegmentSize, GapForDwarf, EndAddress);
+ transferSegmentAndSections(
+ LCI, InputBinary.getSegmentLoadCommand(LCI), InputBinary, Writer,
+ SymtabStart, StringStart + NewStringsSize - SymtabStart, EHFrameStart,
+ EHFrameSize, DwarfSegmentSize, GapForDwarf, EndAddress);
else if (LCI.C.cmd == MachO::LC_SEGMENT_64)
- transferSegmentAndSections(
- LCI, InputBinary.getSegment64LoadCommand(LCI), InputBinary, Writer,
- SymtabStart, StringStart + NewStringsSize - SymtabStart, EHFrameStart,
- EHFrameSize, DwarfSegmentSize, GapForDwarf, EndAddress);
+ transferSegmentAndSections(
+ LCI, InputBinary.getSegment64LoadCommand(LCI), InputBinary, Writer,
+ SymtabStart, StringStart + NewStringsSize - SymtabStart, EHFrameStart,
+ EHFrameSize, DwarfSegmentSize, GapForDwarf, EndAddress);
}
uint64_t DwarfVMAddr = alignTo(EndAddress, 0x1000);
@@ -594,17 +594,17 @@ bool generateDsymCompanion(llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS,
}
assert(OutFile.tell() == StringStart + NewStringsSize);
- // Pad till the EH frame start.
- OutFile.write_zeros(EHFrameStart - (StringStart + NewStringsSize));
- assert(OutFile.tell() == EHFrameStart);
-
- // Transfer eh_frame.
- if (EHFrameSize > 0)
- OutFile << EHFrameData;
- assert(OutFile.tell() == EHFrameStart + EHFrameSize);
-
+ // Pad till the EH frame start.
+ OutFile.write_zeros(EHFrameStart - (StringStart + NewStringsSize));
+ assert(OutFile.tell() == EHFrameStart);
+
+ // Transfer eh_frame.
+ if (EHFrameSize > 0)
+ OutFile << EHFrameData;
+ assert(OutFile.tell() == EHFrameStart + EHFrameSize);
+
// Pad till the Dwarf segment start.
- OutFile.write_zeros(DwarfSegmentStart - (EHFrameStart + EHFrameSize));
+ OutFile.write_zeros(DwarfSegmentStart - (EHFrameStart + EHFrameSize));
assert(OutFile.tell() == DwarfSegmentStart);
// Emit the Dwarf sections contents.
diff --git a/contrib/libs/llvm12/tools/dsymutil/SymbolMap.cpp b/contrib/libs/llvm12/tools/dsymutil/SymbolMap.cpp
index 07a54795a8..0897b824a3 100644
--- a/contrib/libs/llvm12/tools/dsymutil/SymbolMap.cpp
+++ b/contrib/libs/llvm12/tools/dsymutil/SymbolMap.cpp
@@ -47,7 +47,7 @@ StringRef SymbolMapTranslator::operator()(StringRef Input) {
return Translation;
// Objective-C symbols for the MachO symbol table start with a \1. Please see
- // `MangleContext::mangleObjCMethodName` in clang.
+ // `MangleContext::mangleObjCMethodName` in clang.
if (Translation[0] == 1)
return StringRef(Translation).drop_front();
diff --git a/contrib/libs/llvm12/tools/dsymutil/dsymutil.cpp b/contrib/libs/llvm12/tools/dsymutil/dsymutil.cpp
index 347b2dd916..528a5d8848 100644
--- a/contrib/libs/llvm12/tools/dsymutil/dsymutil.cpp
+++ b/contrib/libs/llvm12/tools/dsymutil/dsymutil.cpp
@@ -17,7 +17,7 @@
#include "LinkUtils.h"
#include "MachOUtils.h"
#include "Reproducer.h"
-#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
@@ -157,7 +157,7 @@ static Error verifyOptions(const DsymutilOptions &Options) {
errc::invalid_argument);
}
- if (Options.LinkOpts.Update && llvm::is_contained(Options.InputFiles, "-")) {
+ if (Options.LinkOpts.Update && llvm::is_contained(Options.InputFiles, "-")) {
// FIXME: We cannot use stdin for an update because stdin will be
// consumed by the BinaryHolder during the debugmap parsing, and
// then we will want to consume it again in DwarfLinker. If we
diff --git a/contrib/libs/llvm12/tools/dsymutil/ya.make b/contrib/libs/llvm12/tools/dsymutil/ya.make
index 8a3b747e01..a243a1c5a4 100644
--- a/contrib/libs/llvm12/tools/dsymutil/ya.make
+++ b/contrib/libs/llvm12/tools/dsymutil/ya.make
@@ -12,69 +12,69 @@ LICENSE(Apache-2.0 WITH LLVM-exception)
LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
PEERDIR(
- contrib/libs/llvm12
- contrib/libs/llvm12/include
- contrib/libs/llvm12/lib/Analysis
- contrib/libs/llvm12/lib/AsmParser
- contrib/libs/llvm12/lib/BinaryFormat
- contrib/libs/llvm12/lib/Bitcode/Reader
- contrib/libs/llvm12/lib/Bitcode/Writer
- contrib/libs/llvm12/lib/Bitstream/Reader
- contrib/libs/llvm12/lib/CodeGen
- contrib/libs/llvm12/lib/CodeGen/AsmPrinter
- contrib/libs/llvm12/lib/CodeGen/GlobalISel
- contrib/libs/llvm12/lib/CodeGen/SelectionDAG
- contrib/libs/llvm12/lib/DWARFLinker
- contrib/libs/llvm12/lib/DebugInfo/CodeView
- contrib/libs/llvm12/lib/DebugInfo/DWARF
- contrib/libs/llvm12/lib/Demangle
- contrib/libs/llvm12/lib/Frontend/OpenMP
- contrib/libs/llvm12/lib/IR
- contrib/libs/llvm12/lib/IRReader
- contrib/libs/llvm12/lib/Linker
- contrib/libs/llvm12/lib/MC
- contrib/libs/llvm12/lib/MC/MCDisassembler
- contrib/libs/llvm12/lib/MC/MCParser
- contrib/libs/llvm12/lib/Object
- contrib/libs/llvm12/lib/Option
- contrib/libs/llvm12/lib/ProfileData
- contrib/libs/llvm12/lib/Remarks
- contrib/libs/llvm12/lib/Support
- contrib/libs/llvm12/lib/Target
- contrib/libs/llvm12/lib/Target/AArch64
- contrib/libs/llvm12/lib/Target/AArch64/MCTargetDesc
- contrib/libs/llvm12/lib/Target/AArch64/TargetInfo
- contrib/libs/llvm12/lib/Target/AArch64/Utils
- contrib/libs/llvm12/lib/Target/ARM
- contrib/libs/llvm12/lib/Target/ARM/MCTargetDesc
- contrib/libs/llvm12/lib/Target/ARM/TargetInfo
- contrib/libs/llvm12/lib/Target/ARM/Utils
- contrib/libs/llvm12/lib/Target/BPF
- contrib/libs/llvm12/lib/Target/BPF/MCTargetDesc
- contrib/libs/llvm12/lib/Target/BPF/TargetInfo
- contrib/libs/llvm12/lib/Target/NVPTX
- contrib/libs/llvm12/lib/Target/NVPTX/MCTargetDesc
- contrib/libs/llvm12/lib/Target/NVPTX/TargetInfo
- contrib/libs/llvm12/lib/Target/PowerPC
- contrib/libs/llvm12/lib/Target/PowerPC/MCTargetDesc
- contrib/libs/llvm12/lib/Target/PowerPC/TargetInfo
- contrib/libs/llvm12/lib/Target/X86
- contrib/libs/llvm12/lib/Target/X86/MCTargetDesc
- contrib/libs/llvm12/lib/Target/X86/TargetInfo
- contrib/libs/llvm12/lib/TextAPI/MachO
- contrib/libs/llvm12/lib/Transforms/AggressiveInstCombine
- contrib/libs/llvm12/lib/Transforms/CFGuard
- contrib/libs/llvm12/lib/Transforms/IPO
- contrib/libs/llvm12/lib/Transforms/InstCombine
- contrib/libs/llvm12/lib/Transforms/Instrumentation
- contrib/libs/llvm12/lib/Transforms/Scalar
- contrib/libs/llvm12/lib/Transforms/Utils
- contrib/libs/llvm12/lib/Transforms/Vectorize
+ contrib/libs/llvm12
+ contrib/libs/llvm12/include
+ contrib/libs/llvm12/lib/Analysis
+ contrib/libs/llvm12/lib/AsmParser
+ contrib/libs/llvm12/lib/BinaryFormat
+ contrib/libs/llvm12/lib/Bitcode/Reader
+ contrib/libs/llvm12/lib/Bitcode/Writer
+ contrib/libs/llvm12/lib/Bitstream/Reader
+ contrib/libs/llvm12/lib/CodeGen
+ contrib/libs/llvm12/lib/CodeGen/AsmPrinter
+ contrib/libs/llvm12/lib/CodeGen/GlobalISel
+ contrib/libs/llvm12/lib/CodeGen/SelectionDAG
+ contrib/libs/llvm12/lib/DWARFLinker
+ contrib/libs/llvm12/lib/DebugInfo/CodeView
+ contrib/libs/llvm12/lib/DebugInfo/DWARF
+ contrib/libs/llvm12/lib/Demangle
+ contrib/libs/llvm12/lib/Frontend/OpenMP
+ contrib/libs/llvm12/lib/IR
+ contrib/libs/llvm12/lib/IRReader
+ contrib/libs/llvm12/lib/Linker
+ contrib/libs/llvm12/lib/MC
+ contrib/libs/llvm12/lib/MC/MCDisassembler
+ contrib/libs/llvm12/lib/MC/MCParser
+ contrib/libs/llvm12/lib/Object
+ contrib/libs/llvm12/lib/Option
+ contrib/libs/llvm12/lib/ProfileData
+ contrib/libs/llvm12/lib/Remarks
+ contrib/libs/llvm12/lib/Support
+ contrib/libs/llvm12/lib/Target
+ contrib/libs/llvm12/lib/Target/AArch64
+ contrib/libs/llvm12/lib/Target/AArch64/MCTargetDesc
+ contrib/libs/llvm12/lib/Target/AArch64/TargetInfo
+ contrib/libs/llvm12/lib/Target/AArch64/Utils
+ contrib/libs/llvm12/lib/Target/ARM
+ contrib/libs/llvm12/lib/Target/ARM/MCTargetDesc
+ contrib/libs/llvm12/lib/Target/ARM/TargetInfo
+ contrib/libs/llvm12/lib/Target/ARM/Utils
+ contrib/libs/llvm12/lib/Target/BPF
+ contrib/libs/llvm12/lib/Target/BPF/MCTargetDesc
+ contrib/libs/llvm12/lib/Target/BPF/TargetInfo
+ contrib/libs/llvm12/lib/Target/NVPTX
+ contrib/libs/llvm12/lib/Target/NVPTX/MCTargetDesc
+ contrib/libs/llvm12/lib/Target/NVPTX/TargetInfo
+ contrib/libs/llvm12/lib/Target/PowerPC
+ contrib/libs/llvm12/lib/Target/PowerPC/MCTargetDesc
+ contrib/libs/llvm12/lib/Target/PowerPC/TargetInfo
+ contrib/libs/llvm12/lib/Target/X86
+ contrib/libs/llvm12/lib/Target/X86/MCTargetDesc
+ contrib/libs/llvm12/lib/Target/X86/TargetInfo
+ contrib/libs/llvm12/lib/TextAPI/MachO
+ contrib/libs/llvm12/lib/Transforms/AggressiveInstCombine
+ contrib/libs/llvm12/lib/Transforms/CFGuard
+ contrib/libs/llvm12/lib/Transforms/IPO
+ contrib/libs/llvm12/lib/Transforms/InstCombine
+ contrib/libs/llvm12/lib/Transforms/Instrumentation
+ contrib/libs/llvm12/lib/Transforms/Scalar
+ contrib/libs/llvm12/lib/Transforms/Utils
+ contrib/libs/llvm12/lib/Transforms/Vectorize
)
ADDINCL(
- ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/dsymutil
- contrib/libs/llvm12/tools/dsymutil
+ ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/dsymutil
+ contrib/libs/llvm12/tools/dsymutil
)
NO_COMPILER_WARNINGS()
@@ -94,10 +94,10 @@ SRCS(
)
IF (OS_DARWIN AND ARCH_AARCH64)
- LDFLAGS(
+ LDFLAGS(
-framework
CoreFoundation
- )
+ )
ENDIF()
END()
diff --git a/contrib/libs/llvm12/tools/llvm-cvtres/llvm-cvtres.cpp b/contrib/libs/llvm12/tools/llvm-cvtres/llvm-cvtres.cpp
index 11cfb466e1..8810faf985 100644
--- a/contrib/libs/llvm12/tools/llvm-cvtres/llvm-cvtres.cpp
+++ b/contrib/libs/llvm12/tools/llvm-cvtres/llvm-cvtres.cpp
@@ -66,7 +66,7 @@ public:
};
}
-static LLVM_ATTRIBUTE_NORETURN void reportError(Twine Msg) {
+static LLVM_ATTRIBUTE_NORETURN void reportError(Twine Msg) {
errs() << Msg;
exit(1);
}
@@ -75,7 +75,7 @@ static void reportError(StringRef Input, std::error_code EC) {
reportError(Twine(Input) + ": " + EC.message() + ".\n");
}
-static void error(Error EC) {
+static void error(Error EC) {
if (!EC)
return;
handleAllErrors(std::move(EC),
diff --git a/contrib/libs/llvm12/tools/llvm-cvtres/ya.make b/contrib/libs/llvm12/tools/llvm-cvtres/ya.make
index fc7b01fdb7..9de91aedc9 100644
--- a/contrib/libs/llvm12/tools/llvm-cvtres/ya.make
+++ b/contrib/libs/llvm12/tools/llvm-cvtres/ya.make
@@ -12,25 +12,25 @@ LICENSE(Apache-2.0 WITH LLVM-exception)
LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
PEERDIR(
- contrib/libs/llvm12
- contrib/libs/llvm12/include
- contrib/libs/llvm12/lib/BinaryFormat
- contrib/libs/llvm12/lib/Bitcode/Reader
- contrib/libs/llvm12/lib/Bitstream/Reader
- contrib/libs/llvm12/lib/Demangle
- contrib/libs/llvm12/lib/IR
- contrib/libs/llvm12/lib/MC
- contrib/libs/llvm12/lib/MC/MCParser
- contrib/libs/llvm12/lib/Object
- contrib/libs/llvm12/lib/Option
- contrib/libs/llvm12/lib/Remarks
- contrib/libs/llvm12/lib/Support
- contrib/libs/llvm12/lib/TextAPI/MachO
+ contrib/libs/llvm12
+ contrib/libs/llvm12/include
+ contrib/libs/llvm12/lib/BinaryFormat
+ contrib/libs/llvm12/lib/Bitcode/Reader
+ contrib/libs/llvm12/lib/Bitstream/Reader
+ contrib/libs/llvm12/lib/Demangle
+ contrib/libs/llvm12/lib/IR
+ contrib/libs/llvm12/lib/MC
+ contrib/libs/llvm12/lib/MC/MCParser
+ contrib/libs/llvm12/lib/Object
+ contrib/libs/llvm12/lib/Option
+ contrib/libs/llvm12/lib/Remarks
+ contrib/libs/llvm12/lib/Support
+ contrib/libs/llvm12/lib/TextAPI/MachO
)
ADDINCL(
- ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-cvtres
- contrib/libs/llvm12/tools/llvm-cvtres
+ ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-cvtres
+ contrib/libs/llvm12/tools/llvm-cvtres
)
NO_COMPILER_WARNINGS()
diff --git a/contrib/libs/llvm12/tools/llvm-lipo/llvm-lipo.cpp b/contrib/libs/llvm12/tools/llvm-lipo/llvm-lipo.cpp
index 7fbe489ecc..425434092a 100644
--- a/contrib/libs/llvm12/tools/llvm-lipo/llvm-lipo.cpp
+++ b/contrib/libs/llvm12/tools/llvm-lipo/llvm-lipo.cpp
@@ -12,14 +12,14 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/Triple.h"
-#include "llvm/BinaryFormat/MachO.h"
-#include "llvm/IR/LLVMContext.h"
-#include "llvm/IR/Module.h"
+#include "llvm/BinaryFormat/MachO.h"
+#include "llvm/IR/LLVMContext.h"
+#include "llvm/IR/Module.h"
#include "llvm/Object/Binary.h"
-#include "llvm/Object/IRObjectFile.h"
+#include "llvm/Object/IRObjectFile.h"
#include "llvm/Object/MachO.h"
#include "llvm/Object/MachOUniversal.h"
-#include "llvm/Object/MachOUniversalWriter.h"
+#include "llvm/Object/MachOUniversalWriter.h"
#include "llvm/Object/ObjectFile.h"
#include "llvm/Option/Arg.h"
#include "llvm/Option/ArgList.h"
@@ -34,7 +34,7 @@ using namespace llvm;
using namespace llvm::object;
static const StringRef ToolName = "llvm-lipo";
-static LLVMContext LLVMCtx;
+static LLVMContext LLVMCtx;
LLVM_ATTRIBUTE_NORETURN static void reportError(Twine Message) {
WithColor::error(errs(), ToolName) << Message << "\n";
@@ -42,15 +42,15 @@ LLVM_ATTRIBUTE_NORETURN static void reportError(Twine Message) {
exit(EXIT_FAILURE);
}
-LLVM_ATTRIBUTE_NORETURN static void reportError(Error E) {
- assert(E);
- std::string Buf;
- raw_string_ostream OS(Buf);
- logAllUnhandledErrors(std::move(E), OS);
- OS.flush();
- reportError(Buf);
-}
-
+LLVM_ATTRIBUTE_NORETURN static void reportError(Error E) {
+ assert(E);
+ std::string Buf;
+ raw_string_ostream OS(Buf);
+ logAllUnhandledErrors(std::move(E), OS);
+ OS.flush();
+ reportError(Buf);
+}
+
LLVM_ATTRIBUTE_NORETURN static void reportError(StringRef File, Error E) {
assert(E);
std::string Buf;
@@ -118,18 +118,18 @@ struct Config {
LipoAction ActionToPerform;
};
-static Slice createSliceFromArchive(const Archive &A) {
- Expected<Slice> ArchiveOrSlice = Slice::create(A, &LLVMCtx);
- if (!ArchiveOrSlice)
- reportError(A.getFileName(), ArchiveOrSlice.takeError());
- return *ArchiveOrSlice;
+static Slice createSliceFromArchive(const Archive &A) {
+ Expected<Slice> ArchiveOrSlice = Slice::create(A, &LLVMCtx);
+ if (!ArchiveOrSlice)
+ reportError(A.getFileName(), ArchiveOrSlice.takeError());
+ return *ArchiveOrSlice;
}
-static Slice createSliceFromIR(const IRObjectFile &IRO, unsigned Align) {
- Expected<Slice> IROrErr = Slice::create(IRO, Align);
- if (!IROrErr)
- reportError(IRO.getFileName(), IROrErr.takeError());
- return *IROrErr;
+static Slice createSliceFromIR(const IRObjectFile &IRO, unsigned Align) {
+ Expected<Slice> IROrErr = Slice::create(IRO, Align);
+ if (!IROrErr)
+ reportError(IRO.getFileName(), IROrErr.takeError());
+ return *IROrErr;
}
} // end namespace
@@ -319,20 +319,20 @@ static SmallVector<OwningBinary<Binary>, 1>
readInputBinaries(ArrayRef<InputFile> InputFiles) {
SmallVector<OwningBinary<Binary>, 1> InputBinaries;
for (const InputFile &IF : InputFiles) {
- Expected<OwningBinary<Binary>> BinaryOrErr =
- createBinary(IF.FileName, &LLVMCtx);
+ Expected<OwningBinary<Binary>> BinaryOrErr =
+ createBinary(IF.FileName, &LLVMCtx);
if (!BinaryOrErr)
reportError(IF.FileName, BinaryOrErr.takeError());
const Binary *B = BinaryOrErr->getBinary();
- if (!B->isArchive() && !B->isMachO() && !B->isMachOUniversalBinary() &&
- !B->isIR())
+ if (!B->isArchive() && !B->isMachO() && !B->isMachOUniversalBinary() &&
+ !B->isIR())
reportError("File " + IF.FileName + " has unsupported binary format");
- if (IF.ArchType && (B->isMachO() || B->isArchive() || B->isIR())) {
- const auto S = B->isMachO()
- ? Slice(*cast<MachOObjectFile>(B))
- : B->isArchive()
- ? createSliceFromArchive(*cast<Archive>(B))
- : createSliceFromIR(*cast<IRObjectFile>(B), 0);
+ if (IF.ArchType && (B->isMachO() || B->isArchive() || B->isIR())) {
+ const auto S = B->isMachO()
+ ? Slice(*cast<MachOObjectFile>(B))
+ : B->isArchive()
+ ? createSliceFromArchive(*cast<Archive>(B))
+ : createSliceFromIR(*cast<IRObjectFile>(B), 0);
const auto SpecifiedCPUType = MachO::getCPUTypeFromArchitecture(
MachO::getArchitectureFromName(
Triple(*IF.ArchType).getArchName()))
@@ -384,53 +384,53 @@ static void printBinaryArchs(const Binary *Binary, raw_ostream &OS) {
// Prints trailing space for compatibility with cctools lipo.
if (auto UO = dyn_cast<MachOUniversalBinary>(Binary)) {
for (const auto &O : UO->objects()) {
- // Order here is important, because both MachOObjectFile and
- // IRObjectFile can be created with a binary that has embedded bitcode.
+ // Order here is important, because both MachOObjectFile and
+ // IRObjectFile can be created with a binary that has embedded bitcode.
Expected<std::unique_ptr<MachOObjectFile>> MachOObjOrError =
O.getAsObjectFile();
if (MachOObjOrError) {
- OS << Slice(*(MachOObjOrError->get())).getArchString() << " ";
- continue;
- }
- Expected<std::unique_ptr<IRObjectFile>> IROrError =
- O.getAsIRObject(LLVMCtx);
- if (IROrError) {
- consumeError(MachOObjOrError.takeError());
- Expected<Slice> SliceOrErr = Slice::create(**IROrError, O.getAlign());
- if (!SliceOrErr) {
- reportError(Binary->getFileName(), SliceOrErr.takeError());
- continue;
- }
- OS << SliceOrErr.get().getArchString() << " ";
+ OS << Slice(*(MachOObjOrError->get())).getArchString() << " ";
continue;
}
+ Expected<std::unique_ptr<IRObjectFile>> IROrError =
+ O.getAsIRObject(LLVMCtx);
+ if (IROrError) {
+ consumeError(MachOObjOrError.takeError());
+ Expected<Slice> SliceOrErr = Slice::create(**IROrError, O.getAlign());
+ if (!SliceOrErr) {
+ reportError(Binary->getFileName(), SliceOrErr.takeError());
+ continue;
+ }
+ OS << SliceOrErr.get().getArchString() << " ";
+ continue;
+ }
Expected<std::unique_ptr<Archive>> ArchiveOrError = O.getAsArchive();
if (ArchiveOrError) {
consumeError(MachOObjOrError.takeError());
- consumeError(IROrError.takeError());
- OS << createSliceFromArchive(**ArchiveOrError).getArchString() << " ";
+ consumeError(IROrError.takeError());
+ OS << createSliceFromArchive(**ArchiveOrError).getArchString() << " ";
continue;
}
consumeError(ArchiveOrError.takeError());
reportError(Binary->getFileName(), MachOObjOrError.takeError());
- reportError(Binary->getFileName(), IROrError.takeError());
+ reportError(Binary->getFileName(), IROrError.takeError());
}
OS << "\n";
return;
}
-
- if (const auto *MachO = dyn_cast<MachOObjectFile>(Binary)) {
- OS << Slice(*MachO).getArchString() << " \n";
- return;
- }
-
- // This should be always the case, as this is tested in readInputBinaries
- const auto *IR = cast<IRObjectFile>(Binary);
- Expected<Slice> SliceOrErr = createSliceFromIR(*IR, 0);
- if (!SliceOrErr)
- reportError(IR->getFileName(), SliceOrErr.takeError());
-
- OS << SliceOrErr->getArchString() << " \n";
+
+ if (const auto *MachO = dyn_cast<MachOObjectFile>(Binary)) {
+ OS << Slice(*MachO).getArchString() << " \n";
+ return;
+ }
+
+ // This should be always the case, as this is tested in readInputBinaries
+ const auto *IR = cast<IRObjectFile>(Binary);
+ Expected<Slice> SliceOrErr = createSliceFromIR(*IR, 0);
+ if (!SliceOrErr)
+ reportError(IR->getFileName(), SliceOrErr.takeError());
+
+ OS << SliceOrErr->getArchString() << " \n";
}
LLVM_ATTRIBUTE_NORETURN
@@ -480,23 +480,23 @@ static void thinSlice(ArrayRef<OwningBinary<Binary>> InputBinaries,
auto *UO = cast<MachOUniversalBinary>(InputBinaries.front().getBinary());
Expected<std::unique_ptr<MachOObjectFile>> Obj =
UO->getMachOObjectForArch(ArchType);
- Expected<std::unique_ptr<IRObjectFile>> IRObj =
- UO->getIRObjectForArch(ArchType, LLVMCtx);
+ Expected<std::unique_ptr<IRObjectFile>> IRObj =
+ UO->getIRObjectForArch(ArchType, LLVMCtx);
Expected<std::unique_ptr<Archive>> Ar = UO->getArchiveForArch(ArchType);
- if (!Obj && !IRObj && !Ar)
+ if (!Obj && !IRObj && !Ar)
reportError("fat input file " + UO->getFileName() +
" does not contain the specified architecture " + ArchType +
" to thin it to");
- Binary *B;
- // Order here is important, because both Obj and IRObj will be valid with a
- // binary that has embedded bitcode.
- if (Obj)
- B = Obj->get();
- else if (IRObj)
- B = IRObj->get();
- else
- B = Ar->get();
-
+ Binary *B;
+ // Order here is important, because both Obj and IRObj will be valid with a
+ // binary that has embedded bitcode.
+ if (Obj)
+ B = Obj->get();
+ else if (IRObj)
+ B = IRObj->get();
+ else
+ B = Ar->get();
+
Expected<std::unique_ptr<FileOutputBuffer>> OutFileOrError =
FileOutputBuffer::create(OutputFileName,
B->getMemoryBufferRef().getBufferSize(),
@@ -538,8 +538,8 @@ static void updateAlignments(Range &Slices,
static void checkUnusedAlignments(ArrayRef<Slice> Slices,
const StringMap<const uint32_t> &Alignments) {
auto HasArch = [&](StringRef Arch) {
- return llvm::any_of(Slices,
- [Arch](Slice S) { return S.getArchString() == Arch; });
+ return llvm::any_of(Slices,
+ [Arch](Slice S) { return S.getArchString() == Arch; });
};
for (StringRef Arch : Alignments.keys())
if (!HasArch(Arch))
@@ -550,47 +550,47 @@ static void checkUnusedAlignments(ArrayRef<Slice> Slices,
// Updates vector ExtractedObjects with the MachOObjectFiles extracted from
// Universal Binary files to transfer ownership.
-static SmallVector<Slice, 2>
-buildSlices(ArrayRef<OwningBinary<Binary>> InputBinaries,
- const StringMap<const uint32_t> &Alignments,
- SmallVectorImpl<std::unique_ptr<SymbolicFile>> &ExtractedObjects) {
+static SmallVector<Slice, 2>
+buildSlices(ArrayRef<OwningBinary<Binary>> InputBinaries,
+ const StringMap<const uint32_t> &Alignments,
+ SmallVectorImpl<std::unique_ptr<SymbolicFile>> &ExtractedObjects) {
SmallVector<Slice, 2> Slices;
for (auto &IB : InputBinaries) {
const Binary *InputBinary = IB.getBinary();
if (auto UO = dyn_cast<MachOUniversalBinary>(InputBinary)) {
for (const auto &O : UO->objects()) {
- // Order here is important, because both MachOObjectFile and
- // IRObjectFile can be created with a binary that has embedded bitcode.
+ // Order here is important, because both MachOObjectFile and
+ // IRObjectFile can be created with a binary that has embedded bitcode.
Expected<std::unique_ptr<MachOObjectFile>> BinaryOrError =
O.getAsObjectFile();
- if (BinaryOrError) {
- Slices.emplace_back(*(BinaryOrError.get()), O.getAlign());
- ExtractedObjects.push_back(std::move(BinaryOrError.get()));
- continue;
- }
- Expected<std::unique_ptr<IRObjectFile>> IROrError =
- O.getAsIRObject(LLVMCtx);
- if (IROrError) {
- consumeError(BinaryOrError.takeError());
- Slice S = createSliceFromIR(**IROrError, O.getAlign());
- ExtractedObjects.emplace_back(std::move(IROrError.get()));
- Slices.emplace_back(std::move(S));
- continue;
- }
- reportError(InputBinary->getFileName(), BinaryOrError.takeError());
+ if (BinaryOrError) {
+ Slices.emplace_back(*(BinaryOrError.get()), O.getAlign());
+ ExtractedObjects.push_back(std::move(BinaryOrError.get()));
+ continue;
+ }
+ Expected<std::unique_ptr<IRObjectFile>> IROrError =
+ O.getAsIRObject(LLVMCtx);
+ if (IROrError) {
+ consumeError(BinaryOrError.takeError());
+ Slice S = createSliceFromIR(**IROrError, O.getAlign());
+ ExtractedObjects.emplace_back(std::move(IROrError.get()));
+ Slices.emplace_back(std::move(S));
+ continue;
+ }
+ reportError(InputBinary->getFileName(), BinaryOrError.takeError());
}
- } else if (const auto *O = dyn_cast<MachOObjectFile>(InputBinary)) {
- Slices.emplace_back(*O);
- } else if (const auto *A = dyn_cast<Archive>(InputBinary)) {
- Slices.push_back(createSliceFromArchive(*A));
- } else if (const auto *IRO = dyn_cast<IRObjectFile>(InputBinary)) {
- // Original Apple's lipo set the alignment to 0
- Expected<Slice> SliceOrErr = Slice::create(*IRO, 0);
- if (!SliceOrErr) {
- reportError(InputBinary->getFileName(), SliceOrErr.takeError());
- continue;
- }
- Slices.emplace_back(std::move(SliceOrErr.get()));
+ } else if (const auto *O = dyn_cast<MachOObjectFile>(InputBinary)) {
+ Slices.emplace_back(*O);
+ } else if (const auto *A = dyn_cast<Archive>(InputBinary)) {
+ Slices.push_back(createSliceFromArchive(*A));
+ } else if (const auto *IRO = dyn_cast<IRObjectFile>(InputBinary)) {
+ // Original Apple's lipo set the alignment to 0
+ Expected<Slice> SliceOrErr = Slice::create(*IRO, 0);
+ if (!SliceOrErr) {
+ reportError(InputBinary->getFileName(), SliceOrErr.takeError());
+ continue;
+ }
+ Slices.emplace_back(std::move(SliceOrErr.get()));
} else {
llvm_unreachable("Unexpected binary format");
}
@@ -606,16 +606,16 @@ static void createUniversalBinary(ArrayRef<OwningBinary<Binary>> InputBinaries,
assert(InputBinaries.size() >= 1 && "Incorrect number of input binaries");
assert(!OutputFileName.empty() && "Create expects a single output file");
- SmallVector<std::unique_ptr<SymbolicFile>, 1> ExtractedObjects;
+ SmallVector<std::unique_ptr<SymbolicFile>, 1> ExtractedObjects;
SmallVector<Slice, 1> Slices =
buildSlices(InputBinaries, Alignments, ExtractedObjects);
checkArchDuplicates(Slices);
checkUnusedAlignments(Slices, Alignments);
- llvm::stable_sort(Slices);
- if (Error E = writeUniversalBinary(Slices, OutputFileName))
- reportError(std::move(E));
-
+ llvm::stable_sort(Slices);
+ if (Error E = writeUniversalBinary(Slices, OutputFileName))
+ reportError(std::move(E));
+
exit(EXIT_SUCCESS);
}
@@ -634,7 +634,7 @@ static void extractSlice(ArrayRef<OwningBinary<Binary>> InputBinaries,
" must be a fat file when the -extract option is specified");
}
- SmallVector<std::unique_ptr<SymbolicFile>, 2> ExtractedObjects;
+ SmallVector<std::unique_ptr<SymbolicFile>, 2> ExtractedObjects;
SmallVector<Slice, 2> Slices =
buildSlices(InputBinaries, Alignments, ExtractedObjects);
erase_if(Slices, [ArchType](const Slice &S) {
@@ -645,10 +645,10 @@ static void extractSlice(ArrayRef<OwningBinary<Binary>> InputBinaries,
reportError(
"fat input file " + InputBinaries.front().getBinary()->getFileName() +
" does not contain the specified architecture " + ArchType);
-
- llvm::stable_sort(Slices);
- if (Error E = writeUniversalBinary(Slices, OutputFileName))
- reportError(std::move(E));
+
+ llvm::stable_sort(Slices);
+ if (Error E = writeUniversalBinary(Slices, OutputFileName))
+ reportError(std::move(E));
exit(EXIT_SUCCESS);
}
@@ -664,7 +664,7 @@ buildReplacementSlices(ArrayRef<OwningBinary<Binary>> ReplacementBinaries,
if (!O)
reportError("replacement file: " + ReplacementBinary->getFileName() +
" is a fat file (must be a thin file)");
- Slice S(*O);
+ Slice S(*O);
auto Entry = Slices.try_emplace(S.getArchString(), S);
if (!Entry.second)
reportError("-replace " + S.getArchString() +
@@ -696,7 +696,7 @@ static void replaceSlices(ArrayRef<OwningBinary<Binary>> InputBinaries,
StringMap<Slice> ReplacementSlices =
buildReplacementSlices(ReplacementBinaries, Alignments);
- SmallVector<std::unique_ptr<SymbolicFile>, 2> ExtractedObjects;
+ SmallVector<std::unique_ptr<SymbolicFile>, 2> ExtractedObjects;
SmallVector<Slice, 2> Slices =
buildSlices(InputBinaries, Alignments, ExtractedObjects);
@@ -715,10 +715,10 @@ static void replaceSlices(ArrayRef<OwningBinary<Binary>> InputBinaries,
" does not contain that architecture");
checkUnusedAlignments(Slices, Alignments);
-
- llvm::stable_sort(Slices);
- if (Error E = writeUniversalBinary(Slices, OutputFileName))
- reportError(std::move(E));
+
+ llvm::stable_sort(Slices);
+ if (Error E = writeUniversalBinary(Slices, OutputFileName))
+ reportError(std::move(E));
exit(EXIT_SUCCESS);
}
diff --git a/contrib/libs/llvm12/tools/llvm-lipo/ya.make b/contrib/libs/llvm12/tools/llvm-lipo/ya.make
index afb28b31ce..a48a15a45e 100644
--- a/contrib/libs/llvm12/tools/llvm-lipo/ya.make
+++ b/contrib/libs/llvm12/tools/llvm-lipo/ya.make
@@ -12,55 +12,55 @@ LICENSE(Apache-2.0 WITH LLVM-exception)
LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
PEERDIR(
- contrib/libs/llvm12
- contrib/libs/llvm12/include
- contrib/libs/llvm12/lib/BinaryFormat
- contrib/libs/llvm12/lib/Bitcode/Reader
- contrib/libs/llvm12/lib/Bitstream/Reader
- contrib/libs/llvm12/lib/Demangle
- contrib/libs/llvm12/lib/IR
- contrib/libs/llvm12/lib/MC
- contrib/libs/llvm12/lib/MC/MCParser
- contrib/libs/llvm12/lib/Object
- contrib/libs/llvm12/lib/Option
- contrib/libs/llvm12/lib/Remarks
- contrib/libs/llvm12/lib/Support
- contrib/libs/llvm12/lib/Target/AArch64
- contrib/libs/llvm12/lib/Target/AArch64/AsmParser
- contrib/libs/llvm12/lib/Target/AArch64/Disassembler
- contrib/libs/llvm12/lib/Target/AArch64/MCTargetDesc
- contrib/libs/llvm12/lib/Target/AArch64/TargetInfo
- contrib/libs/llvm12/lib/Target/AArch64/Utils
- contrib/libs/llvm12/lib/Target/ARM
- contrib/libs/llvm12/lib/Target/ARM/AsmParser
- contrib/libs/llvm12/lib/Target/ARM/Disassembler
- contrib/libs/llvm12/lib/Target/ARM/MCTargetDesc
- contrib/libs/llvm12/lib/Target/ARM/TargetInfo
- contrib/libs/llvm12/lib/Target/ARM/Utils
- contrib/libs/llvm12/lib/Target/BPF
- contrib/libs/llvm12/lib/Target/BPF/AsmParser
- contrib/libs/llvm12/lib/Target/BPF/Disassembler
- contrib/libs/llvm12/lib/Target/BPF/MCTargetDesc
- contrib/libs/llvm12/lib/Target/BPF/TargetInfo
- contrib/libs/llvm12/lib/Target/NVPTX
- contrib/libs/llvm12/lib/Target/NVPTX/MCTargetDesc
- contrib/libs/llvm12/lib/Target/NVPTX/TargetInfo
- contrib/libs/llvm12/lib/Target/PowerPC
- contrib/libs/llvm12/lib/Target/PowerPC/AsmParser
- contrib/libs/llvm12/lib/Target/PowerPC/Disassembler
- contrib/libs/llvm12/lib/Target/PowerPC/MCTargetDesc
- contrib/libs/llvm12/lib/Target/PowerPC/TargetInfo
- contrib/libs/llvm12/lib/Target/X86
- contrib/libs/llvm12/lib/Target/X86/AsmParser
- contrib/libs/llvm12/lib/Target/X86/Disassembler
- contrib/libs/llvm12/lib/Target/X86/MCTargetDesc
- contrib/libs/llvm12/lib/Target/X86/TargetInfo
- contrib/libs/llvm12/lib/TextAPI/MachO
+ contrib/libs/llvm12
+ contrib/libs/llvm12/include
+ contrib/libs/llvm12/lib/BinaryFormat
+ contrib/libs/llvm12/lib/Bitcode/Reader
+ contrib/libs/llvm12/lib/Bitstream/Reader
+ contrib/libs/llvm12/lib/Demangle
+ contrib/libs/llvm12/lib/IR
+ contrib/libs/llvm12/lib/MC
+ contrib/libs/llvm12/lib/MC/MCParser
+ contrib/libs/llvm12/lib/Object
+ contrib/libs/llvm12/lib/Option
+ contrib/libs/llvm12/lib/Remarks
+ contrib/libs/llvm12/lib/Support
+ contrib/libs/llvm12/lib/Target/AArch64
+ contrib/libs/llvm12/lib/Target/AArch64/AsmParser
+ contrib/libs/llvm12/lib/Target/AArch64/Disassembler
+ contrib/libs/llvm12/lib/Target/AArch64/MCTargetDesc
+ contrib/libs/llvm12/lib/Target/AArch64/TargetInfo
+ contrib/libs/llvm12/lib/Target/AArch64/Utils
+ contrib/libs/llvm12/lib/Target/ARM
+ contrib/libs/llvm12/lib/Target/ARM/AsmParser
+ contrib/libs/llvm12/lib/Target/ARM/Disassembler
+ contrib/libs/llvm12/lib/Target/ARM/MCTargetDesc
+ contrib/libs/llvm12/lib/Target/ARM/TargetInfo
+ contrib/libs/llvm12/lib/Target/ARM/Utils
+ contrib/libs/llvm12/lib/Target/BPF
+ contrib/libs/llvm12/lib/Target/BPF/AsmParser
+ contrib/libs/llvm12/lib/Target/BPF/Disassembler
+ contrib/libs/llvm12/lib/Target/BPF/MCTargetDesc
+ contrib/libs/llvm12/lib/Target/BPF/TargetInfo
+ contrib/libs/llvm12/lib/Target/NVPTX
+ contrib/libs/llvm12/lib/Target/NVPTX/MCTargetDesc
+ contrib/libs/llvm12/lib/Target/NVPTX/TargetInfo
+ contrib/libs/llvm12/lib/Target/PowerPC
+ contrib/libs/llvm12/lib/Target/PowerPC/AsmParser
+ contrib/libs/llvm12/lib/Target/PowerPC/Disassembler
+ contrib/libs/llvm12/lib/Target/PowerPC/MCTargetDesc
+ contrib/libs/llvm12/lib/Target/PowerPC/TargetInfo
+ contrib/libs/llvm12/lib/Target/X86
+ contrib/libs/llvm12/lib/Target/X86/AsmParser
+ contrib/libs/llvm12/lib/Target/X86/Disassembler
+ contrib/libs/llvm12/lib/Target/X86/MCTargetDesc
+ contrib/libs/llvm12/lib/Target/X86/TargetInfo
+ contrib/libs/llvm12/lib/TextAPI/MachO
)
ADDINCL(
- ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-lipo
- contrib/libs/llvm12/tools/llvm-lipo
+ ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-lipo
+ contrib/libs/llvm12/tools/llvm-lipo
)
NO_COMPILER_WARNINGS()
diff --git a/contrib/libs/llvm12/tools/llvm-ml/Opts.td b/contrib/libs/llvm12/tools/llvm-ml/Opts.td
index 4c2757b057..4e4766484d 100644
--- a/contrib/libs/llvm12/tools/llvm-ml/Opts.td
+++ b/contrib/libs/llvm12/tools/llvm-ml/Opts.td
@@ -1,110 +1,110 @@
-include "llvm/Option/OptParser.td"
-
-// For LLVM-specific options, we prefer a two-dash prefix, but accept one for
-// compatibility with llvm-mc. For clear separation from ML.EXE compatible
-// options, slash is not accepted.
-class LLVMFlag<string name> : Flag<["--", "-"], name>;
-class LLVMJoined<string name> : Joined<["--", "-"], name>;
-class LLVMJoinedOrSeparate<string name> : JoinedOrSeparate<["--", "-"], name>;
-class LLVMSeparate<string name> : Separate<["--", "-"], name>;
-
-def ml_Group : OptionGroup<"<ml options>">,
- HelpText<"ML.EXE COMPATIBILITY OPTIONS">;
-class MLFlag<string name> : Flag<["/", "-"], name>, Group<ml_Group>;
-class MLJoined<string name> : Joined<["/", "-"], name>, Group<ml_Group>;
-class MLJoinedOrSeparate<string name> : JoinedOrSeparate<["/", "-"], name>,
- Group<ml_Group>;
-class MLSeparate<string name> : Separate<["/", "-"], name>, Group<ml_Group>;
-
-def unsupported_Group : OptionGroup<"unsupported">, Flags<[HelpHidden]>,
- HelpText<"UNSUPPORTED ML.EXE COMPATIBILITY OPTIONS">;
-class UnsupportedFlag<string name> : Flag<["/", "-"], name>,
- Group<unsupported_Group>;
-class UnsupportedJoined<string name> : Joined<["/", "-"], name>,
- Group<unsupported_Group>;
-class UnsupportedJoinedOrSeparate<string name> :
- JoinedOrSeparate<["/", "-"], name>, Group<unsupported_Group>;
-class UnsupportedSeparate<string name> : Separate<["/", "-"], name>,
- Group<unsupported_Group>;
-
-def help : MLFlag<"?">,
- HelpText<"Display available options">;
-def help_long : MLFlag<"help">, Alias<help>;
-def assemble_only : MLFlag<"c">, HelpText<"Assemble only; do not link">;
-def define : MLJoinedOrSeparate<"D">, MetaVarName<"<macro>=<value>">,
- HelpText<"Define <macro> to <value> (or blank if <value> "
- "omitted)">;
-def output_file : MLJoinedOrSeparate<"Fo">, HelpText<"Names the output file">;
-def include_path : MLJoinedOrSeparate<"I">,
- HelpText<"Sets path for include files">;
-def safeseh : MLFlag<"safeseh">,
- HelpText<"Mark resulting object files as either containing no "
- "exception handlers or containing exception handlers "
- "that are all declared with .SAFESEH. Only available in "
- "32-bit.">;
-def assembly_file : MLJoinedOrSeparate<"Ta">,
- HelpText<"Assemble source file with name not ending with "
- "the .asm extension">;
-
-def bitness : LLVMJoined<"m">, Values<"32,64">,
- HelpText<"Target platform (x86 or x86-64)">;
-def as_lex : LLVMFlag<"as-lex">,
- HelpText<"Lex tokens from a .asm file without assembling">;
-def filetype : LLVMJoined<"filetype=">, Values<"obj,s,null">,
- HelpText<"Emit a file with the given type">;
-def output_att_asm : LLVMFlag<"output-att-asm">,
- HelpText<"Use ATT syntax for output assembly">;
-def show_encoding : LLVMFlag<"show-encoding">,
- HelpText<"Show instruction encodings in output assembly">;
-def show_inst : LLVMFlag<"show-inst">,
- HelpText<"Show internal instruction representation in output "
- "assembly">;
-def show_inst_operands : LLVMFlag<"show-inst-operands">,
- HelpText<"Show instructions operands as parsed">;
-def print_imm_hex : LLVMFlag<"print-imm-hex">,
- HelpText<"Prefer hex format for immediate values in output "
- "assembly">;
-def preserve_comments : LLVMFlag<"preserve-comments">,
- HelpText<"Preserve comments in output assembly">;
-def save_temp_labels : LLVMFlag<"save-temp-labels">,
- HelpText<"Don't discard temporary labels">;
-
-def tiny_model_support : UnsupportedFlag<"AT">, HelpText<"">;
-def alternate_linker : UnsupportedJoined<"Bl">, HelpText<"">;
-def coff_object_file : UnsupportedFlag<"coff">, HelpText<"">;
-def preserve_identifier_case : UnsupportedFlag<"Cp">, HelpText<"">;
-def uppercase_identifiers : UnsupportedFlag<"Cu">, HelpText<"">;
-def preserve_extern_case : UnsupportedFlag<"Cx">, HelpText<"">;
-def output_preprocessed : UnsupportedFlag<"EP">, HelpText<"">;
-def errorreport : UnsupportedJoined<"ERRORREPORT">, HelpText<"">;
-def stacksize : UnsupportedSeparate<"F">, HelpText<"">;
-def executable_file : UnsupportedSeparate<"Fe">, HelpText<"">;
-def code_listing_file : UnsupportedJoined<"FI">, HelpText<"">;
-def linker_map_file : UnsupportedJoined<"Fm">, HelpText<"">;
-def fp_emulator_fixups : UnsupportedFlag<"FPi">, HelpText<"">;
-def source_browser_file : UnsupportedJoined<"Fr">, HelpText<"">;
-def extended_source_browser_file : UnsupportedJoined<"FR">, HelpText<"">;
-def pascal_conventions : UnsupportedFlag<"Gc">, HelpText<"">;
-def c_conventions : UnsupportedFlag<"Gd">, HelpText<"">;
-def stdcall_conventions : UnsupportedFlag<"GZ">, HelpText<"">;
-def extern_name_limit : UnsupportedSeparate<"H">, HelpText<"">;
-def nologo : UnsupportedFlag<"nologo">, HelpText<"">;
-def omf_object_file : UnsupportedFlag<"omf">, HelpText<"">;
-def full_listing : UnsupportedFlag<"Sa">, HelpText<"">;
-def first_pass_listing : UnsupportedFlag<"Sf">, HelpText<"">;
-def listing_width : UnsupportedSeparate<"SI">, HelpText<"">;
-def listing_without_symbols : UnsupportedFlag<"Sn">, HelpText<"">;
-def listing_page_length : UnsupportedSeparate<"Sp">, HelpText<"">;
-def listing_subtitle : UnsupportedSeparate<"Ss">, HelpText<"">;
-def listing_title : UnsupportedSeparate<"St">, HelpText<"">;
-def listing_false_conditionals : UnsupportedFlag<"Sx">, HelpText<"">;
-def extra_warnings : UnsupportedFlag<"w">, HelpText<"">;
-def warning_level : UnsupportedJoined<"W">, HelpText<"">;
-def error_on_warning : UnsupportedFlag<"WX">, HelpText<"">;
-def ignore_include_envvar : UnsupportedFlag<"X">, HelpText<"">;
-def line_number_info : UnsupportedFlag<"Zd">, HelpText<"">;
-def export_all_symbols : UnsupportedFlag<"Zf">, HelpText<"">;
-def codeview_info : UnsupportedFlag<"Zi">, HelpText<"">;
-def enable_m510_option : UnsupportedFlag<"Zm">, HelpText<"">;
-def structure_packing : UnsupportedJoined<"Zp">, HelpText<"">;
-def parse_only : UnsupportedFlag<"Zs">, HelpText<"">;
+include "llvm/Option/OptParser.td"
+
+// For LLVM-specific options, we prefer a two-dash prefix, but accept one for
+// compatibility with llvm-mc. For clear separation from ML.EXE compatible
+// options, slash is not accepted.
+class LLVMFlag<string name> : Flag<["--", "-"], name>;
+class LLVMJoined<string name> : Joined<["--", "-"], name>;
+class LLVMJoinedOrSeparate<string name> : JoinedOrSeparate<["--", "-"], name>;
+class LLVMSeparate<string name> : Separate<["--", "-"], name>;
+
+def ml_Group : OptionGroup<"<ml options>">,
+ HelpText<"ML.EXE COMPATIBILITY OPTIONS">;
+class MLFlag<string name> : Flag<["/", "-"], name>, Group<ml_Group>;
+class MLJoined<string name> : Joined<["/", "-"], name>, Group<ml_Group>;
+class MLJoinedOrSeparate<string name> : JoinedOrSeparate<["/", "-"], name>,
+ Group<ml_Group>;
+class MLSeparate<string name> : Separate<["/", "-"], name>, Group<ml_Group>;
+
+def unsupported_Group : OptionGroup<"unsupported">, Flags<[HelpHidden]>,
+ HelpText<"UNSUPPORTED ML.EXE COMPATIBILITY OPTIONS">;
+class UnsupportedFlag<string name> : Flag<["/", "-"], name>,
+ Group<unsupported_Group>;
+class UnsupportedJoined<string name> : Joined<["/", "-"], name>,
+ Group<unsupported_Group>;
+class UnsupportedJoinedOrSeparate<string name> :
+ JoinedOrSeparate<["/", "-"], name>, Group<unsupported_Group>;
+class UnsupportedSeparate<string name> : Separate<["/", "-"], name>,
+ Group<unsupported_Group>;
+
+def help : MLFlag<"?">,
+ HelpText<"Display available options">;
+def help_long : MLFlag<"help">, Alias<help>;
+def assemble_only : MLFlag<"c">, HelpText<"Assemble only; do not link">;
+def define : MLJoinedOrSeparate<"D">, MetaVarName<"<macro>=<value>">,
+ HelpText<"Define <macro> to <value> (or blank if <value> "
+ "omitted)">;
+def output_file : MLJoinedOrSeparate<"Fo">, HelpText<"Names the output file">;
+def include_path : MLJoinedOrSeparate<"I">,
+ HelpText<"Sets path for include files">;
+def safeseh : MLFlag<"safeseh">,
+ HelpText<"Mark resulting object files as either containing no "
+ "exception handlers or containing exception handlers "
+ "that are all declared with .SAFESEH. Only available in "
+ "32-bit.">;
+def assembly_file : MLJoinedOrSeparate<"Ta">,
+ HelpText<"Assemble source file with name not ending with "
+ "the .asm extension">;
+
+def bitness : LLVMJoined<"m">, Values<"32,64">,
+ HelpText<"Target platform (x86 or x86-64)">;
+def as_lex : LLVMFlag<"as-lex">,
+ HelpText<"Lex tokens from a .asm file without assembling">;
+def filetype : LLVMJoined<"filetype=">, Values<"obj,s,null">,
+ HelpText<"Emit a file with the given type">;
+def output_att_asm : LLVMFlag<"output-att-asm">,
+ HelpText<"Use ATT syntax for output assembly">;
+def show_encoding : LLVMFlag<"show-encoding">,
+ HelpText<"Show instruction encodings in output assembly">;
+def show_inst : LLVMFlag<"show-inst">,
+ HelpText<"Show internal instruction representation in output "
+ "assembly">;
+def show_inst_operands : LLVMFlag<"show-inst-operands">,
+ HelpText<"Show instructions operands as parsed">;
+def print_imm_hex : LLVMFlag<"print-imm-hex">,
+ HelpText<"Prefer hex format for immediate values in output "
+ "assembly">;
+def preserve_comments : LLVMFlag<"preserve-comments">,
+ HelpText<"Preserve comments in output assembly">;
+def save_temp_labels : LLVMFlag<"save-temp-labels">,
+ HelpText<"Don't discard temporary labels">;
+
+def tiny_model_support : UnsupportedFlag<"AT">, HelpText<"">;
+def alternate_linker : UnsupportedJoined<"Bl">, HelpText<"">;
+def coff_object_file : UnsupportedFlag<"coff">, HelpText<"">;
+def preserve_identifier_case : UnsupportedFlag<"Cp">, HelpText<"">;
+def uppercase_identifiers : UnsupportedFlag<"Cu">, HelpText<"">;
+def preserve_extern_case : UnsupportedFlag<"Cx">, HelpText<"">;
+def output_preprocessed : UnsupportedFlag<"EP">, HelpText<"">;
+def errorreport : UnsupportedJoined<"ERRORREPORT">, HelpText<"">;
+def stacksize : UnsupportedSeparate<"F">, HelpText<"">;
+def executable_file : UnsupportedSeparate<"Fe">, HelpText<"">;
+def code_listing_file : UnsupportedJoined<"FI">, HelpText<"">;
+def linker_map_file : UnsupportedJoined<"Fm">, HelpText<"">;
+def fp_emulator_fixups : UnsupportedFlag<"FPi">, HelpText<"">;
+def source_browser_file : UnsupportedJoined<"Fr">, HelpText<"">;
+def extended_source_browser_file : UnsupportedJoined<"FR">, HelpText<"">;
+def pascal_conventions : UnsupportedFlag<"Gc">, HelpText<"">;
+def c_conventions : UnsupportedFlag<"Gd">, HelpText<"">;
+def stdcall_conventions : UnsupportedFlag<"GZ">, HelpText<"">;
+def extern_name_limit : UnsupportedSeparate<"H">, HelpText<"">;
+def nologo : UnsupportedFlag<"nologo">, HelpText<"">;
+def omf_object_file : UnsupportedFlag<"omf">, HelpText<"">;
+def full_listing : UnsupportedFlag<"Sa">, HelpText<"">;
+def first_pass_listing : UnsupportedFlag<"Sf">, HelpText<"">;
+def listing_width : UnsupportedSeparate<"SI">, HelpText<"">;
+def listing_without_symbols : UnsupportedFlag<"Sn">, HelpText<"">;
+def listing_page_length : UnsupportedSeparate<"Sp">, HelpText<"">;
+def listing_subtitle : UnsupportedSeparate<"Ss">, HelpText<"">;
+def listing_title : UnsupportedSeparate<"St">, HelpText<"">;
+def listing_false_conditionals : UnsupportedFlag<"Sx">, HelpText<"">;
+def extra_warnings : UnsupportedFlag<"w">, HelpText<"">;
+def warning_level : UnsupportedJoined<"W">, HelpText<"">;
+def error_on_warning : UnsupportedFlag<"WX">, HelpText<"">;
+def ignore_include_envvar : UnsupportedFlag<"X">, HelpText<"">;
+def line_number_info : UnsupportedFlag<"Zd">, HelpText<"">;
+def export_all_symbols : UnsupportedFlag<"Zf">, HelpText<"">;
+def codeview_info : UnsupportedFlag<"Zi">, HelpText<"">;
+def enable_m510_option : UnsupportedFlag<"Zm">, HelpText<"">;
+def structure_packing : UnsupportedJoined<"Zp">, HelpText<"">;
+def parse_only : UnsupportedFlag<"Zs">, HelpText<"">;
diff --git a/contrib/libs/llvm12/tools/llvm-ml/llvm-ml.cpp b/contrib/libs/llvm12/tools/llvm-ml/llvm-ml.cpp
index 1733dcd472..5c21d0bb40 100644
--- a/contrib/libs/llvm12/tools/llvm-ml/llvm-ml.cpp
+++ b/contrib/libs/llvm12/tools/llvm-ml/llvm-ml.cpp
@@ -10,7 +10,7 @@
//
//===----------------------------------------------------------------------===//
-#include "llvm/ADT/StringSwitch.h"
+#include "llvm/ADT/StringSwitch.h"
#include "llvm/MC/MCAsmBackend.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCCodeEmitter.h"
@@ -25,17 +25,17 @@
#include "llvm/MC/MCStreamer.h"
#include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/MC/MCTargetOptionsCommandFlags.h"
-#include "llvm/Option/Arg.h"
-#include "llvm/Option/ArgList.h"
-#include "llvm/Option/Option.h"
+#include "llvm/Option/Arg.h"
+#include "llvm/Option/ArgList.h"
+#include "llvm/Option/Option.h"
#include "llvm/Support/Compression.h"
#include "llvm/Support/FileUtilities.h"
-#include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/FormattedStream.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/InitLLVM.h"
#include "llvm/Support/MemoryBuffer.h"
-#include "llvm/Support/Path.h"
+#include "llvm/Support/Path.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/TargetRegistry.h"
#include "llvm/Support/TargetSelect.h"
@@ -43,55 +43,55 @@
#include "llvm/Support/WithColor.h"
using namespace llvm;
-using namespace llvm::opt;
+using namespace llvm::opt;
-namespace {
+namespace {
-enum ID {
- OPT_INVALID = 0, // This is not an option ID.
-#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
- HELPTEXT, METAVAR, VALUES) \
- OPT_##ID,
-#include "Opts.inc"
-#undef OPTION
+enum ID {
+ OPT_INVALID = 0, // This is not an option ID.
+#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
+ HELPTEXT, METAVAR, VALUES) \
+ OPT_##ID,
+#include "Opts.inc"
+#undef OPTION
};
-#define PREFIX(NAME, VALUE) const char *const NAME[] = VALUE;
-#include "Opts.inc"
-#undef PREFIX
-
-static const opt::OptTable::Info InfoTable[] = {
-#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
- HELPTEXT, METAVAR, VALUES) \
- { \
- PREFIX, NAME, HELPTEXT, \
- METAVAR, OPT_##ID, opt::Option::KIND##Class, \
- PARAM, FLAGS, OPT_##GROUP, \
- OPT_##ALIAS, ALIASARGS, VALUES},
-#include "Opts.inc"
-#undef OPTION
+#define PREFIX(NAME, VALUE) const char *const NAME[] = VALUE;
+#include "Opts.inc"
+#undef PREFIX
+
+static const opt::OptTable::Info InfoTable[] = {
+#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
+ HELPTEXT, METAVAR, VALUES) \
+ { \
+ PREFIX, NAME, HELPTEXT, \
+ METAVAR, OPT_##ID, opt::Option::KIND##Class, \
+ PARAM, FLAGS, OPT_##GROUP, \
+ OPT_##ALIAS, ALIASARGS, VALUES},
+#include "Opts.inc"
+#undef OPTION
};
-class MLOptTable : public opt::OptTable {
-public:
- MLOptTable() : OptTable(InfoTable, /*IgnoreCase=*/false) {}
+class MLOptTable : public opt::OptTable {
+public:
+ MLOptTable() : OptTable(InfoTable, /*IgnoreCase=*/false) {}
};
-} // namespace
+} // namespace
-static Triple GetTriple(StringRef ProgName, opt::InputArgList &Args) {
+static Triple GetTriple(StringRef ProgName, opt::InputArgList &Args) {
// Figure out the target triple.
- StringRef DefaultBitness = "32";
- SmallString<255> Program = ProgName;
- sys::path::replace_extension(Program, "");
- if (Program.endswith("ml64"))
- DefaultBitness = "64";
-
- StringRef TripleName =
- StringSwitch<StringRef>(Args.getLastArgValue(OPT_bitness, DefaultBitness))
- .Case("32", "i386-pc-windows")
- .Case("64", "x86_64-pc-windows")
- .Default("");
- return Triple(Triple::normalize(TripleName));
+ StringRef DefaultBitness = "32";
+ SmallString<255> Program = ProgName;
+ sys::path::replace_extension(Program, "");
+ if (Program.endswith("ml64"))
+ DefaultBitness = "64";
+
+ StringRef TripleName =
+ StringSwitch<StringRef>(Args.getLastArgValue(OPT_bitness, DefaultBitness))
+ .Case("32", "i386-pc-windows")
+ .Case("64", "x86_64-pc-windows")
+ .Default("");
+ return Triple(Triple::normalize(TripleName));
}
static std::unique_ptr<ToolOutputFile> GetOutputStream(StringRef Path) {
@@ -108,10 +108,10 @@ static std::unique_ptr<ToolOutputFile> GetOutputStream(StringRef Path) {
static int AsLexInput(SourceMgr &SrcMgr, MCAsmInfo &MAI, raw_ostream &OS) {
AsmLexer Lexer(MAI);
Lexer.setBuffer(SrcMgr.getMemoryBuffer(SrcMgr.getMainFileID())->getBuffer());
- Lexer.setLexMasmIntegers(true);
- Lexer.useMasmDefaultRadix(true);
- Lexer.setLexMasmHexFloats(true);
- Lexer.setLexMasmStrings(true);
+ Lexer.setLexMasmIntegers(true);
+ Lexer.useMasmDefaultRadix(true);
+ Lexer.setLexMasmHexFloats(true);
+ Lexer.setLexMasmStrings(true);
bool Error = false;
while (Lexer.Lex().isNot(AsmToken::Eof)) {
@@ -124,13 +124,13 @@ static int AsLexInput(SourceMgr &SrcMgr, MCAsmInfo &MAI, raw_ostream &OS) {
return Error;
}
-static int AssembleInput(StringRef ProgName, const Target *TheTarget,
+static int AssembleInput(StringRef ProgName, const Target *TheTarget,
SourceMgr &SrcMgr, MCContext &Ctx, MCStreamer &Str,
MCAsmInfo &MAI, MCSubtargetInfo &STI,
- MCInstrInfo &MCII, MCTargetOptions &MCOptions,
- const opt::ArgList &InputArgs) {
+ MCInstrInfo &MCII, MCTargetOptions &MCOptions,
+ const opt::ArgList &InputArgs) {
std::unique_ptr<MCAsmParser> Parser(
- createMCMasmParser(SrcMgr, Ctx, Str, MAI, 0));
+ createMCMasmParser(SrcMgr, Ctx, Str, MAI, 0));
std::unique_ptr<MCTargetAsmParser> TAP(
TheTarget->createMCAsmParser(STI, *Parser, MCII, MCOptions));
@@ -140,32 +140,32 @@ static int AssembleInput(StringRef ProgName, const Target *TheTarget,
return 1;
}
- Parser->setShowParsedOperands(InputArgs.hasArg(OPT_show_inst_operands));
+ Parser->setShowParsedOperands(InputArgs.hasArg(OPT_show_inst_operands));
Parser->setTargetParser(*TAP);
Parser->getLexer().setLexMasmIntegers(true);
- Parser->getLexer().useMasmDefaultRadix(true);
- Parser->getLexer().setLexMasmHexFloats(true);
- Parser->getLexer().setLexMasmStrings(true);
-
- auto Defines = InputArgs.getAllArgValues(OPT_define);
- for (StringRef Define : Defines) {
- const auto NameValue = Define.split('=');
- StringRef Name = NameValue.first, Value = NameValue.second;
- if (Parser->defineMacro(Name, Value)) {
- WithColor::error(errs(), ProgName)
- << "can't define macro '" << Name << "' = '" << Value << "'\n";
- return 1;
- }
- }
-
+ Parser->getLexer().useMasmDefaultRadix(true);
+ Parser->getLexer().setLexMasmHexFloats(true);
+ Parser->getLexer().setLexMasmStrings(true);
+
+ auto Defines = InputArgs.getAllArgValues(OPT_define);
+ for (StringRef Define : Defines) {
+ const auto NameValue = Define.split('=');
+ StringRef Name = NameValue.first, Value = NameValue.second;
+ if (Parser->defineMacro(Name, Value)) {
+ WithColor::error(errs(), ProgName)
+ << "can't define macro '" << Name << "' = '" << Value << "'\n";
+ return 1;
+ }
+ }
+
int Res = Parser->Run(/*NoInitialTextSection=*/true);
return Res;
}
-int main(int Argc, char **Argv) {
- InitLLVM X(Argc, Argv);
- StringRef ProgName = sys::path::filename(Argv[0]);
+int main(int Argc, char **Argv) {
+ InitLLVM X(Argc, Argv);
+ StringRef ProgName = sys::path::filename(Argv[0]);
// Initialize targets and assembly printers/parsers.
llvm::InitializeAllTargetInfos();
@@ -173,81 +173,81 @@ int main(int Argc, char **Argv) {
llvm::InitializeAllAsmParsers();
llvm::InitializeAllDisassemblers();
- MLOptTable T;
- unsigned MissingArgIndex, MissingArgCount;
- ArrayRef<const char *> ArgsArr = makeArrayRef(Argv + 1, Argc - 1);
- opt::InputArgList InputArgs =
- T.ParseArgs(ArgsArr, MissingArgIndex, MissingArgCount);
-
- std::string InputFilename;
- for (auto *Arg : InputArgs.filtered(OPT_INPUT)) {
- std::string ArgString = Arg->getAsString(InputArgs);
- if (ArgString == "-" || StringRef(ArgString).endswith(".asm")) {
- if (!InputFilename.empty()) {
- WithColor::warning(errs(), ProgName)
- << "does not support multiple assembly files in one command; "
- << "ignoring '" << InputFilename << "'\n";
- }
- InputFilename = ArgString;
- } else {
- std::string Diag;
- raw_string_ostream OS(Diag);
- OS << "invalid option '" << ArgString << "'";
-
- std::string Nearest;
- if (T.findNearest(ArgString, Nearest) < 2)
- OS << ", did you mean '" << Nearest << "'?";
-
- WithColor::error(errs(), ProgName) << OS.str() << '\n';
- exit(1);
- }
- }
- for (auto *Arg : InputArgs.filtered(OPT_assembly_file)) {
- if (!InputFilename.empty()) {
- WithColor::warning(errs(), ProgName)
- << "does not support multiple assembly files in one command; "
- << "ignoring '" << InputFilename << "'\n";
- }
- InputFilename = Arg->getAsString(InputArgs);
- }
-
- for (auto *Arg : InputArgs.filtered(OPT_unsupported_Group)) {
- WithColor::warning(errs(), ProgName)
- << "ignoring unsupported '" << Arg->getOption().getName()
- << "' option\n";
- }
-
- if (InputArgs.hasArg(OPT_help)) {
- std::string Usage = llvm::formatv("{0} [ /options ] file", ProgName).str();
- T.PrintHelp(outs(), Usage.c_str(), "LLVM MASM Assembler",
- /*ShowHidden=*/false);
- return 0;
- } else if (InputFilename.empty()) {
- outs() << "USAGE: " << ProgName << " [ /options ] file\n"
- << "Run \"" << ProgName << " /?\" or \"" << ProgName
- << " /help\" for more info.\n";
- return 0;
- }
-
- MCTargetOptions MCOptions;
+ MLOptTable T;
+ unsigned MissingArgIndex, MissingArgCount;
+ ArrayRef<const char *> ArgsArr = makeArrayRef(Argv + 1, Argc - 1);
+ opt::InputArgList InputArgs =
+ T.ParseArgs(ArgsArr, MissingArgIndex, MissingArgCount);
+
+ std::string InputFilename;
+ for (auto *Arg : InputArgs.filtered(OPT_INPUT)) {
+ std::string ArgString = Arg->getAsString(InputArgs);
+ if (ArgString == "-" || StringRef(ArgString).endswith(".asm")) {
+ if (!InputFilename.empty()) {
+ WithColor::warning(errs(), ProgName)
+ << "does not support multiple assembly files in one command; "
+ << "ignoring '" << InputFilename << "'\n";
+ }
+ InputFilename = ArgString;
+ } else {
+ std::string Diag;
+ raw_string_ostream OS(Diag);
+ OS << "invalid option '" << ArgString << "'";
+
+ std::string Nearest;
+ if (T.findNearest(ArgString, Nearest) < 2)
+ OS << ", did you mean '" << Nearest << "'?";
+
+ WithColor::error(errs(), ProgName) << OS.str() << '\n';
+ exit(1);
+ }
+ }
+ for (auto *Arg : InputArgs.filtered(OPT_assembly_file)) {
+ if (!InputFilename.empty()) {
+ WithColor::warning(errs(), ProgName)
+ << "does not support multiple assembly files in one command; "
+ << "ignoring '" << InputFilename << "'\n";
+ }
+ InputFilename = Arg->getAsString(InputArgs);
+ }
+
+ for (auto *Arg : InputArgs.filtered(OPT_unsupported_Group)) {
+ WithColor::warning(errs(), ProgName)
+ << "ignoring unsupported '" << Arg->getOption().getName()
+ << "' option\n";
+ }
+
+ if (InputArgs.hasArg(OPT_help)) {
+ std::string Usage = llvm::formatv("{0} [ /options ] file", ProgName).str();
+ T.PrintHelp(outs(), Usage.c_str(), "LLVM MASM Assembler",
+ /*ShowHidden=*/false);
+ return 0;
+ } else if (InputFilename.empty()) {
+ outs() << "USAGE: " << ProgName << " [ /options ] file\n"
+ << "Run \"" << ProgName << " /?\" or \"" << ProgName
+ << " /help\" for more info.\n";
+ return 0;
+ }
+
+ MCTargetOptions MCOptions;
MCOptions.AssemblyLanguage = "masm";
- Triple TheTriple = GetTriple(ProgName, InputArgs);
- std::string Error;
- const Target *TheTarget = TargetRegistry::lookupTarget("", TheTriple, Error);
- if (!TheTarget) {
- WithColor::error(errs(), ProgName) << Error;
+ Triple TheTriple = GetTriple(ProgName, InputArgs);
+ std::string Error;
+ const Target *TheTarget = TargetRegistry::lookupTarget("", TheTriple, Error);
+ if (!TheTarget) {
+ WithColor::error(errs(), ProgName) << Error;
return 1;
- }
- const std::string &TripleName = TheTriple.getTriple();
-
- bool SafeSEH = InputArgs.hasArg(OPT_safeseh);
- if (SafeSEH && !(TheTriple.isArch32Bit() && TheTriple.isX86())) {
- WithColor::warning()
- << "/safeseh applies only to 32-bit X86 platforms; ignoring.\n";
- SafeSEH = false;
- }
-
+ }
+ const std::string &TripleName = TheTriple.getTriple();
+
+ bool SafeSEH = InputArgs.hasArg(OPT_safeseh);
+ if (SafeSEH && !(TheTriple.isArch32Bit() && TheTriple.isX86())) {
+ WithColor::warning()
+ << "/safeseh applies only to 32-bit X86 platforms; ignoring.\n";
+ SafeSEH = false;
+ }
+
ErrorOr<std::unique_ptr<MemoryBuffer>> BufferPtr =
MemoryBuffer::getFileOrSTDIN(InputFilename);
if (std::error_code EC = BufferPtr.getError()) {
@@ -263,7 +263,7 @@ int main(int Argc, char **Argv) {
// Record the location of the include directories so that the lexer can find
// it later.
- SrcMgr.setIncludeDirs(InputArgs.getAllArgValues(OPT_include_path));
+ SrcMgr.setIncludeDirs(InputArgs.getAllArgValues(OPT_include_path));
std::unique_ptr<MCRegisterInfo> MRI(TheTarget->createMCRegInfo(TripleName));
assert(MRI && "Unable to create target register info!");
@@ -272,7 +272,7 @@ int main(int Argc, char **Argv) {
TheTarget->createMCAsmInfo(*MRI, TripleName, MCOptions));
assert(MAI && "Unable to create target asm info!");
- MAI->setPreserveAsmComments(InputArgs.hasArg(OPT_preserve_comments));
+ MAI->setPreserveAsmComments(InputArgs.hasArg(OPT_preserve_comments));
// FIXME: This is not pretty. MCContext has a ptr to MCObjectFileInfo and
// MCObjectFileInfo needs a MCContext reference in order to initialize itself.
@@ -281,25 +281,25 @@ int main(int Argc, char **Argv) {
MOFI.InitMCObjectFileInfo(TheTriple, /*PIC=*/false, Ctx,
/*LargeCodeModel=*/true);
- if (InputArgs.hasArg(OPT_save_temp_labels))
+ if (InputArgs.hasArg(OPT_save_temp_labels))
Ctx.setAllowTemporaryLabels(false);
- // Set compilation information.
- SmallString<128> CWD;
- if (!sys::fs::current_path(CWD))
- Ctx.setCompilationDir(CWD);
- Ctx.setMainFileName(InputFilename);
-
- StringRef FileType = InputArgs.getLastArgValue(OPT_filetype, "obj");
- SmallString<255> DefaultOutputFilename;
- if (InputArgs.hasArg(OPT_as_lex)) {
- DefaultOutputFilename = "-";
+ // Set compilation information.
+ SmallString<128> CWD;
+ if (!sys::fs::current_path(CWD))
+ Ctx.setCompilationDir(CWD);
+ Ctx.setMainFileName(InputFilename);
+
+ StringRef FileType = InputArgs.getLastArgValue(OPT_filetype, "obj");
+ SmallString<255> DefaultOutputFilename;
+ if (InputArgs.hasArg(OPT_as_lex)) {
+ DefaultOutputFilename = "-";
} else {
- DefaultOutputFilename = InputFilename;
- sys::path::replace_extension(DefaultOutputFilename, FileType);
+ DefaultOutputFilename = InputFilename;
+ sys::path::replace_extension(DefaultOutputFilename, FileType);
}
- const StringRef OutputFilename =
- InputArgs.getLastArgValue(OPT_output_file, DefaultOutputFilename);
+ const StringRef OutputFilename =
+ InputArgs.getLastArgValue(OPT_output_file, DefaultOutputFilename);
std::unique_ptr<ToolOutputFile> Out = GetOutputStream(OutputFilename);
if (!Out)
return 1;
@@ -309,19 +309,19 @@ int main(int Argc, char **Argv) {
std::unique_ptr<MCStreamer> Str;
std::unique_ptr<MCInstrInfo> MCII(TheTarget->createMCInstrInfo());
- assert(MCII && "Unable to create instruction info!");
-
+ assert(MCII && "Unable to create instruction info!");
+
std::unique_ptr<MCSubtargetInfo> STI(TheTarget->createMCSubtargetInfo(
TripleName, /*CPU=*/"", /*Features=*/""));
- assert(STI && "Unable to create subtarget info!");
+ assert(STI && "Unable to create subtarget info!");
MCInstPrinter *IP = nullptr;
- if (FileType == "s") {
- const bool OutputATTAsm = InputArgs.hasArg(OPT_output_att_asm);
+ if (FileType == "s") {
+ const bool OutputATTAsm = InputArgs.hasArg(OPT_output_att_asm);
const unsigned OutputAsmVariant = OutputATTAsm ? 0U // ATT dialect
: 1U; // Intel dialect
- IP = TheTarget->createMCInstPrinter(TheTriple, OutputAsmVariant, *MAI,
- *MCII, *MRI);
+ IP = TheTarget->createMCInstPrinter(TheTriple, OutputAsmVariant, *MAI,
+ *MCII, *MRI);
if (!IP) {
WithColor::error()
@@ -332,24 +332,24 @@ int main(int Argc, char **Argv) {
}
// Set the display preference for hex vs. decimal immediates.
- IP->setPrintImmHex(InputArgs.hasArg(OPT_print_imm_hex));
+ IP->setPrintImmHex(InputArgs.hasArg(OPT_print_imm_hex));
// Set up the AsmStreamer.
std::unique_ptr<MCCodeEmitter> CE;
- if (InputArgs.hasArg(OPT_show_encoding))
+ if (InputArgs.hasArg(OPT_show_encoding))
CE.reset(TheTarget->createMCCodeEmitter(*MCII, *MRI, Ctx));
std::unique_ptr<MCAsmBackend> MAB(
TheTarget->createMCAsmBackend(*STI, *MRI, MCOptions));
auto FOut = std::make_unique<formatted_raw_ostream>(*OS);
- Str.reset(TheTarget->createAsmStreamer(
- Ctx, std::move(FOut), /*asmverbose*/ true,
- /*useDwarfDirectory*/ true, IP, std::move(CE), std::move(MAB),
- InputArgs.hasArg(OPT_show_inst)));
+ Str.reset(TheTarget->createAsmStreamer(
+ Ctx, std::move(FOut), /*asmverbose*/ true,
+ /*useDwarfDirectory*/ true, IP, std::move(CE), std::move(MAB),
+ InputArgs.hasArg(OPT_show_inst)));
- } else if (FileType == "null") {
+ } else if (FileType == "null") {
Str.reset(TheTarget->createNullStreamer(Ctx));
- } else if (FileType == "obj") {
+ } else if (FileType == "obj") {
if (!Out->os().supportsSeeking()) {
BOS = std::make_unique<buffer_ostream>(Out->os());
OS = BOS.get();
@@ -362,37 +362,37 @@ int main(int Argc, char **Argv) {
MAB->createObjectWriter(*OS), std::unique_ptr<MCCodeEmitter>(CE), *STI,
MCOptions.MCRelaxAll, MCOptions.MCIncrementalLinkerCompatible,
/*DWARFMustBeAtTheEnd*/ false));
- } else {
- llvm_unreachable("Invalid file type!");
- }
-
- if (TheTriple.isOSBinFormatCOFF()) {
- // Emit an absolute @feat.00 symbol. This is a features bitfield read by
- // link.exe.
- int64_t Feat00Flags = 0x2;
- if (SafeSEH) {
- // According to the PE-COFF spec, the LSB of this value marks the object
- // for "registered SEH". This means that all SEH handler entry points
- // must be registered in .sxdata. Use of any unregistered handlers will
- // cause the process to terminate immediately.
- Feat00Flags |= 0x1;
- }
- MCSymbol *Feat00Sym = Ctx.getOrCreateSymbol("@feat.00");
- Feat00Sym->setRedefinable(true);
- Str->emitSymbolAttribute(Feat00Sym, MCSA_Global);
- Str->emitAssignment(Feat00Sym, MCConstantExpr::create(Feat00Flags, Ctx));
+ } else {
+ llvm_unreachable("Invalid file type!");
}
+ if (TheTriple.isOSBinFormatCOFF()) {
+ // Emit an absolute @feat.00 symbol. This is a features bitfield read by
+ // link.exe.
+ int64_t Feat00Flags = 0x2;
+ if (SafeSEH) {
+ // According to the PE-COFF spec, the LSB of this value marks the object
+ // for "registered SEH". This means that all SEH handler entry points
+ // must be registered in .sxdata. Use of any unregistered handlers will
+ // cause the process to terminate immediately.
+ Feat00Flags |= 0x1;
+ }
+ MCSymbol *Feat00Sym = Ctx.getOrCreateSymbol("@feat.00");
+ Feat00Sym->setRedefinable(true);
+ Str->emitSymbolAttribute(Feat00Sym, MCSA_Global);
+ Str->emitAssignment(Feat00Sym, MCConstantExpr::create(Feat00Flags, Ctx));
+ }
+
// Use Assembler information for parsing.
Str->setUseAssemblerInfoForParsing(true);
int Res = 1;
- if (InputArgs.hasArg(OPT_as_lex)) {
- // -as-lex; Lex only, and output a stream of tokens
+ if (InputArgs.hasArg(OPT_as_lex)) {
+ // -as-lex; Lex only, and output a stream of tokens
Res = AsLexInput(SrcMgr, *MAI, Out->os());
- } else {
+ } else {
Res = AssembleInput(ProgName, TheTarget, SrcMgr, Ctx, *Str, *MAI, *STI,
- *MCII, MCOptions, InputArgs);
+ *MCII, MCOptions, InputArgs);
}
// Keep output if no errors.
diff --git a/contrib/libs/llvm12/tools/llvm-ml/ya.make b/contrib/libs/llvm12/tools/llvm-ml/ya.make
index 5371cfd851..7816f1d57b 100644
--- a/contrib/libs/llvm12/tools/llvm-ml/ya.make
+++ b/contrib/libs/llvm12/tools/llvm-ml/ya.make
@@ -12,44 +12,44 @@ LICENSE(Apache-2.0 WITH LLVM-exception)
LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
PEERDIR(
- contrib/libs/llvm12
- contrib/libs/llvm12/include
- contrib/libs/llvm12/lib/BinaryFormat
- contrib/libs/llvm12/lib/Demangle
- contrib/libs/llvm12/lib/MC
- contrib/libs/llvm12/lib/MC/MCDisassembler
- contrib/libs/llvm12/lib/MC/MCParser
- contrib/libs/llvm12/lib/Option
- contrib/libs/llvm12/lib/Support
- contrib/libs/llvm12/lib/Target/AArch64/AsmParser
- contrib/libs/llvm12/lib/Target/AArch64/Disassembler
- contrib/libs/llvm12/lib/Target/AArch64/MCTargetDesc
- contrib/libs/llvm12/lib/Target/AArch64/TargetInfo
- contrib/libs/llvm12/lib/Target/AArch64/Utils
- contrib/libs/llvm12/lib/Target/ARM/AsmParser
- contrib/libs/llvm12/lib/Target/ARM/Disassembler
- contrib/libs/llvm12/lib/Target/ARM/MCTargetDesc
- contrib/libs/llvm12/lib/Target/ARM/TargetInfo
- contrib/libs/llvm12/lib/Target/ARM/Utils
- contrib/libs/llvm12/lib/Target/BPF/AsmParser
- contrib/libs/llvm12/lib/Target/BPF/Disassembler
- contrib/libs/llvm12/lib/Target/BPF/MCTargetDesc
- contrib/libs/llvm12/lib/Target/BPF/TargetInfo
- contrib/libs/llvm12/lib/Target/NVPTX/MCTargetDesc
- contrib/libs/llvm12/lib/Target/NVPTX/TargetInfo
- contrib/libs/llvm12/lib/Target/PowerPC/AsmParser
- contrib/libs/llvm12/lib/Target/PowerPC/Disassembler
- contrib/libs/llvm12/lib/Target/PowerPC/MCTargetDesc
- contrib/libs/llvm12/lib/Target/PowerPC/TargetInfo
- contrib/libs/llvm12/lib/Target/X86/AsmParser
- contrib/libs/llvm12/lib/Target/X86/Disassembler
- contrib/libs/llvm12/lib/Target/X86/MCTargetDesc
- contrib/libs/llvm12/lib/Target/X86/TargetInfo
+ contrib/libs/llvm12
+ contrib/libs/llvm12/include
+ contrib/libs/llvm12/lib/BinaryFormat
+ contrib/libs/llvm12/lib/Demangle
+ contrib/libs/llvm12/lib/MC
+ contrib/libs/llvm12/lib/MC/MCDisassembler
+ contrib/libs/llvm12/lib/MC/MCParser
+ contrib/libs/llvm12/lib/Option
+ contrib/libs/llvm12/lib/Support
+ contrib/libs/llvm12/lib/Target/AArch64/AsmParser
+ contrib/libs/llvm12/lib/Target/AArch64/Disassembler
+ contrib/libs/llvm12/lib/Target/AArch64/MCTargetDesc
+ contrib/libs/llvm12/lib/Target/AArch64/TargetInfo
+ contrib/libs/llvm12/lib/Target/AArch64/Utils
+ contrib/libs/llvm12/lib/Target/ARM/AsmParser
+ contrib/libs/llvm12/lib/Target/ARM/Disassembler
+ contrib/libs/llvm12/lib/Target/ARM/MCTargetDesc
+ contrib/libs/llvm12/lib/Target/ARM/TargetInfo
+ contrib/libs/llvm12/lib/Target/ARM/Utils
+ contrib/libs/llvm12/lib/Target/BPF/AsmParser
+ contrib/libs/llvm12/lib/Target/BPF/Disassembler
+ contrib/libs/llvm12/lib/Target/BPF/MCTargetDesc
+ contrib/libs/llvm12/lib/Target/BPF/TargetInfo
+ contrib/libs/llvm12/lib/Target/NVPTX/MCTargetDesc
+ contrib/libs/llvm12/lib/Target/NVPTX/TargetInfo
+ contrib/libs/llvm12/lib/Target/PowerPC/AsmParser
+ contrib/libs/llvm12/lib/Target/PowerPC/Disassembler
+ contrib/libs/llvm12/lib/Target/PowerPC/MCTargetDesc
+ contrib/libs/llvm12/lib/Target/PowerPC/TargetInfo
+ contrib/libs/llvm12/lib/Target/X86/AsmParser
+ contrib/libs/llvm12/lib/Target/X86/Disassembler
+ contrib/libs/llvm12/lib/Target/X86/MCTargetDesc
+ contrib/libs/llvm12/lib/Target/X86/TargetInfo
)
ADDINCL(
- ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-ml
- contrib/libs/llvm12/tools/llvm-ml
+ ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-ml
+ contrib/libs/llvm12/tools/llvm-ml
)
NO_COMPILER_WARNINGS()
diff --git a/contrib/libs/llvm12/tools/llvm-mt/llvm-mt.cpp b/contrib/libs/llvm12/tools/llvm-mt/llvm-mt.cpp
index 997e5acbe2..64029c96fc 100644
--- a/contrib/libs/llvm12/tools/llvm-mt/llvm-mt.cpp
+++ b/contrib/libs/llvm12/tools/llvm-mt/llvm-mt.cpp
@@ -64,7 +64,7 @@ public:
};
} // namespace
-LLVM_ATTRIBUTE_NORETURN static void reportError(Twine Msg) {
+LLVM_ATTRIBUTE_NORETURN static void reportError(Twine Msg) {
WithColor::error(errs(), "llvm-mt") << Msg << '\n';
exit(1);
}
@@ -73,7 +73,7 @@ static void reportError(StringRef Input, std::error_code EC) {
reportError(Twine(Input) + ": " + EC.message());
}
-static void error(Error EC) {
+static void error(Error EC) {
if (EC)
handleAllErrors(std::move(EC), [&](const ErrorInfoBase &EI) {
reportError(EI.message());
diff --git a/contrib/libs/llvm12/tools/llvm-mt/ya.make b/contrib/libs/llvm12/tools/llvm-mt/ya.make
index 83a363a067..6a57401b55 100644
--- a/contrib/libs/llvm12/tools/llvm-mt/ya.make
+++ b/contrib/libs/llvm12/tools/llvm-mt/ya.make
@@ -12,17 +12,17 @@ LICENSE(Apache-2.0 WITH LLVM-exception)
LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
PEERDIR(
- contrib/libs/llvm12
- contrib/libs/llvm12/include
- contrib/libs/llvm12/lib/Demangle
- contrib/libs/llvm12/lib/Option
- contrib/libs/llvm12/lib/Support
- contrib/libs/llvm12/lib/WindowsManifest
+ contrib/libs/llvm12
+ contrib/libs/llvm12/include
+ contrib/libs/llvm12/lib/Demangle
+ contrib/libs/llvm12/lib/Option
+ contrib/libs/llvm12/lib/Support
+ contrib/libs/llvm12/lib/WindowsManifest
)
ADDINCL(
- ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-mt
- contrib/libs/llvm12/tools/llvm-mt
+ ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-mt
+ contrib/libs/llvm12/tools/llvm-mt
)
NO_COMPILER_WARNINGS()
diff --git a/contrib/libs/llvm12/tools/llvm-objcopy/BitcodeStripOpts.td b/contrib/libs/llvm12/tools/llvm-objcopy/BitcodeStripOpts.td
index cc178164b0..5abaa3b2ce 100644
--- a/contrib/libs/llvm12/tools/llvm-objcopy/BitcodeStripOpts.td
+++ b/contrib/libs/llvm12/tools/llvm-objcopy/BitcodeStripOpts.td
@@ -1,24 +1,24 @@
-//===-- BitcodeStripOpts.td - llvm-bitcode-strip options ---------------*-===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-//
-// This file describes the command line options of llvm-bitcode-strip.
-//
-//===----------------------------------------------------------------------===//
-
-include "llvm/Option/OptParser.td"
-
-def help : Flag<["--"], "help">;
-
-def h : Flag<["-"], "h">, Alias<help>;
-
-def version : Flag<["--"], "version">,
- HelpText<"Print the version and exit.">;
-
-def V : Flag<["-"], "V">,
- Alias<version>,
- HelpText<"Alias for --version">;
+//===-- BitcodeStripOpts.td - llvm-bitcode-strip options ---------------*-===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+//
+// This file describes the command line options of llvm-bitcode-strip.
+//
+//===----------------------------------------------------------------------===//
+
+include "llvm/Option/OptParser.td"
+
+def help : Flag<["--"], "help">;
+
+def h : Flag<["-"], "h">, Alias<help>;
+
+def version : Flag<["--"], "version">,
+ HelpText<"Print the version and exit.">;
+
+def V : Flag<["-"], "V">,
+ Alias<version>,
+ HelpText<"Alias for --version">;
diff --git a/contrib/libs/llvm12/tools/llvm-objcopy/COFF/COFFObjcopy.cpp b/contrib/libs/llvm12/tools/llvm-objcopy/COFF/COFFObjcopy.cpp
index b5de8a45a8..cb2d66df74 100644
--- a/contrib/libs/llvm12/tools/llvm-objcopy/COFF/COFFObjcopy.cpp
+++ b/contrib/libs/llvm12/tools/llvm-objcopy/COFF/COFFObjcopy.cpp
@@ -39,12 +39,12 @@ static uint64_t getNextRVA(const Object &Obj) {
Obj.IsPE ? Obj.PeHeader.SectionAlignment : 1);
}
-static Expected<std::vector<uint8_t>>
-createGnuDebugLinkSectionContents(StringRef File) {
+static Expected<std::vector<uint8_t>>
+createGnuDebugLinkSectionContents(StringRef File) {
ErrorOr<std::unique_ptr<MemoryBuffer>> LinkTargetOrErr =
MemoryBuffer::getFile(File);
if (!LinkTargetOrErr)
- return createFileError(File, LinkTargetOrErr.getError());
+ return createFileError(File, LinkTargetOrErr.getError());
auto LinkTarget = std::move(*LinkTargetOrErr);
uint32_t CRC32 = llvm::crc32(arrayRefFromStringRef(LinkTarget->getBuffer()));
@@ -81,17 +81,17 @@ static void addSection(Object &Obj, StringRef Name, ArrayRef<uint8_t> Contents,
Obj.addSections(Sec);
}
-static Error addGnuDebugLink(Object &Obj, StringRef DebugLinkFile) {
- Expected<std::vector<uint8_t>> Contents =
+static Error addGnuDebugLink(Object &Obj, StringRef DebugLinkFile) {
+ Expected<std::vector<uint8_t>> Contents =
createGnuDebugLinkSectionContents(DebugLinkFile);
- if (!Contents)
- return Contents.takeError();
-
- addSection(Obj, ".gnu_debuglink", *Contents,
+ if (!Contents)
+ return Contents.takeError();
+
+ addSection(Obj, ".gnu_debuglink", *Contents,
IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ |
IMAGE_SCN_MEM_DISCARDABLE);
-
- return Error::success();
+
+ return Error::success();
}
static void setSectionFlags(Section &Sec, SectionFlag AllFlags) {
@@ -179,7 +179,7 @@ static Error handleArgs(const CopyConfig &Config, Object &Obj) {
Sym.Name = I->getValue();
}
- auto ToRemove = [&](const Symbol &Sym) -> Expected<bool> {
+ auto ToRemove = [&](const Symbol &Sym) -> Expected<bool> {
// For StripAll, all relocations have been stripped and we remove all
// symbols.
if (Config.StripAll || Config.StripAllGNU)
@@ -188,10 +188,10 @@ static Error handleArgs(const CopyConfig &Config, Object &Obj) {
if (Config.SymbolsToRemove.matches(Sym.Name)) {
// Explicitly removing a referenced symbol is an error.
if (Sym.Referenced)
- return createStringError(
- llvm::errc::invalid_argument,
- "'" + Config.OutputFilename + "': not stripping symbol '" +
- Sym.Name.str() + "' because it is named in a relocation");
+ return createStringError(
+ llvm::errc::invalid_argument,
+ "'" + Config.OutputFilename + "': not stripping symbol '" +
+ Sym.Name.str() + "' because it is named in a relocation");
return true;
}
@@ -216,12 +216,12 @@ static Error handleArgs(const CopyConfig &Config, Object &Obj) {
}
return false;
- };
-
- // Actually do removals of symbols.
- if (Error Err = Obj.removeSymbols(ToRemove))
- return Err;
+ };
+ // Actually do removals of symbols.
+ if (Error Err = Obj.removeSymbols(ToRemove))
+ return Err;
+
if (!Config.SetSectionFlags.empty())
for (Section &Sec : Obj.getMutableSections()) {
const auto It = Config.SetSectionFlags.find(Sec.Name);
@@ -246,8 +246,8 @@ static Error handleArgs(const CopyConfig &Config, Object &Obj) {
}
if (!Config.AddGnuDebugLink.empty())
- if (Error E = addGnuDebugLink(Obj, Config.AddGnuDebugLink))
- return E;
+ if (Error E = addGnuDebugLink(Obj, Config.AddGnuDebugLink))
+ return E;
if (Config.AllowBrokenLinks || !Config.BuildIdLinkDir.empty() ||
Config.BuildIdLinkInput || Config.BuildIdLinkOutput ||
diff --git a/contrib/libs/llvm12/tools/llvm-objcopy/COFF/Object.cpp b/contrib/libs/llvm12/tools/llvm-objcopy/COFF/Object.cpp
index 1c17b8408e..166ddce160 100644
--- a/contrib/libs/llvm12/tools/llvm-objcopy/COFF/Object.cpp
+++ b/contrib/libs/llvm12/tools/llvm-objcopy/COFF/Object.cpp
@@ -31,23 +31,23 @@ void Object::updateSymbols() {
}
const Symbol *Object::findSymbol(size_t UniqueId) const {
- return SymbolMap.lookup(UniqueId);
+ return SymbolMap.lookup(UniqueId);
}
-Error Object::removeSymbols(
- function_ref<Expected<bool>(const Symbol &)> ToRemove) {
- Error Errs = Error::success();
- llvm::erase_if(Symbols, [ToRemove, &Errs](const Symbol &Sym) {
- Expected<bool> ShouldRemove = ToRemove(Sym);
- if (!ShouldRemove) {
- Errs = joinErrors(std::move(Errs), ShouldRemove.takeError());
- return false;
- }
- return *ShouldRemove;
- });
-
+Error Object::removeSymbols(
+ function_ref<Expected<bool>(const Symbol &)> ToRemove) {
+ Error Errs = Error::success();
+ llvm::erase_if(Symbols, [ToRemove, &Errs](const Symbol &Sym) {
+ Expected<bool> ShouldRemove = ToRemove(Sym);
+ if (!ShouldRemove) {
+ Errs = joinErrors(std::move(Errs), ShouldRemove.takeError());
+ return false;
+ }
+ return *ShouldRemove;
+ });
+
updateSymbols();
- return Errs;
+ return Errs;
}
Error Object::markSymbols() {
@@ -83,34 +83,34 @@ void Object::updateSections() {
}
const Section *Object::findSection(ssize_t UniqueId) const {
- return SectionMap.lookup(UniqueId);
+ return SectionMap.lookup(UniqueId);
}
void Object::removeSections(function_ref<bool(const Section &)> ToRemove) {
DenseSet<ssize_t> AssociatedSections;
auto RemoveAssociated = [&AssociatedSections](const Section &Sec) {
- return AssociatedSections.contains(Sec.UniqueId);
+ return AssociatedSections.contains(Sec.UniqueId);
};
do {
DenseSet<ssize_t> RemovedSections;
- llvm::erase_if(Sections, [ToRemove, &RemovedSections](const Section &Sec) {
- bool Remove = ToRemove(Sec);
- if (Remove)
- RemovedSections.insert(Sec.UniqueId);
- return Remove;
- });
+ llvm::erase_if(Sections, [ToRemove, &RemovedSections](const Section &Sec) {
+ bool Remove = ToRemove(Sec);
+ if (Remove)
+ RemovedSections.insert(Sec.UniqueId);
+ return Remove;
+ });
// Remove all symbols referring to the removed sections.
AssociatedSections.clear();
- llvm::erase_if(
- Symbols, [&RemovedSections, &AssociatedSections](const Symbol &Sym) {
- // If there are sections that are associative to a removed
- // section,
- // remove those as well as nothing will include them (and we can't
- // leave them dangling).
- if (RemovedSections.count(Sym.AssociativeComdatTargetSectionId) == 1)
- AssociatedSections.insert(Sym.TargetSectionId);
- return RemovedSections.contains(Sym.TargetSectionId);
- });
+ llvm::erase_if(
+ Symbols, [&RemovedSections, &AssociatedSections](const Symbol &Sym) {
+ // If there are sections that are associative to a removed
+ // section,
+ // remove those as well as nothing will include them (and we can't
+ // leave them dangling).
+ if (RemovedSections.count(Sym.AssociativeComdatTargetSectionId) == 1)
+ AssociatedSections.insert(Sym.TargetSectionId);
+ return RemovedSections.contains(Sym.TargetSectionId);
+ });
ToRemove = RemoveAssociated;
} while (!AssociatedSections.empty());
updateSections();
diff --git a/contrib/libs/llvm12/tools/llvm-objcopy/COFF/Object.h b/contrib/libs/llvm12/tools/llvm-objcopy/COFF/Object.h
index 0e854b58cb..77d8467c61 100644
--- a/contrib/libs/llvm12/tools/llvm-objcopy/COFF/Object.h
+++ b/contrib/libs/llvm12/tools/llvm-objcopy/COFF/Object.h
@@ -26,7 +26,7 @@ namespace coff {
struct Relocation {
Relocation() = default;
- Relocation(const object::coff_relocation &R) : Reloc(R) {}
+ Relocation(const object::coff_relocation &R) : Reloc(R) {}
object::coff_relocation Reloc;
size_t Target = 0;
@@ -116,7 +116,7 @@ struct Object {
const Symbol *findSymbol(size_t UniqueId) const;
void addSymbols(ArrayRef<Symbol> NewSymbols);
- Error removeSymbols(function_ref<Expected<bool>(const Symbol &)> ToRemove);
+ Error removeSymbols(function_ref<Expected<bool>(const Symbol &)> ToRemove);
// Set the Referenced field on all Symbols, based on relocations in
// all sections.
diff --git a/contrib/libs/llvm12/tools/llvm-objcopy/CopyConfig.cpp b/contrib/libs/llvm12/tools/llvm-objcopy/CopyConfig.cpp
index ba74759a34..c589508201 100644
--- a/contrib/libs/llvm12/tools/llvm-objcopy/CopyConfig.cpp
+++ b/contrib/libs/llvm12/tools/llvm-objcopy/CopyConfig.cpp
@@ -101,43 +101,43 @@ public:
InstallNameToolOptTable() : OptTable(InstallNameToolInfoTable) {}
};
-enum BitcodeStripID {
- BITCODE_STRIP_INVALID = 0, // This is not an option ID.
-#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
- HELPTEXT, METAVAR, VALUES) \
- BITCODE_STRIP_##ID,
-#include "BitcodeStripOpts.inc"
-#undef OPTION
-};
-
-#define PREFIX(NAME, VALUE) const char *const BITCODE_STRIP_##NAME[] = VALUE;
-#include "BitcodeStripOpts.inc"
-#undef PREFIX
-
-static const opt::OptTable::Info BitcodeStripInfoTable[] = {
-#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
- HELPTEXT, METAVAR, VALUES) \
- {BITCODE_STRIP_##PREFIX, \
- NAME, \
- HELPTEXT, \
- METAVAR, \
- BITCODE_STRIP_##ID, \
- opt::Option::KIND##Class, \
- PARAM, \
- FLAGS, \
- BITCODE_STRIP_##GROUP, \
- BITCODE_STRIP_##ALIAS, \
- ALIASARGS, \
- VALUES},
-#include "BitcodeStripOpts.inc"
-#undef OPTION
-};
-
-class BitcodeStripOptTable : public opt::OptTable {
-public:
- BitcodeStripOptTable() : OptTable(BitcodeStripInfoTable) {}
-};
-
+enum BitcodeStripID {
+ BITCODE_STRIP_INVALID = 0, // This is not an option ID.
+#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
+ HELPTEXT, METAVAR, VALUES) \
+ BITCODE_STRIP_##ID,
+#include "BitcodeStripOpts.inc"
+#undef OPTION
+};
+
+#define PREFIX(NAME, VALUE) const char *const BITCODE_STRIP_##NAME[] = VALUE;
+#include "BitcodeStripOpts.inc"
+#undef PREFIX
+
+static const opt::OptTable::Info BitcodeStripInfoTable[] = {
+#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
+ HELPTEXT, METAVAR, VALUES) \
+ {BITCODE_STRIP_##PREFIX, \
+ NAME, \
+ HELPTEXT, \
+ METAVAR, \
+ BITCODE_STRIP_##ID, \
+ opt::Option::KIND##Class, \
+ PARAM, \
+ FLAGS, \
+ BITCODE_STRIP_##GROUP, \
+ BITCODE_STRIP_##ALIAS, \
+ ALIASARGS, \
+ VALUES},
+#include "BitcodeStripOpts.inc"
+#undef OPTION
+};
+
+class BitcodeStripOptTable : public opt::OptTable {
+public:
+ BitcodeStripOptTable() : OptTable(BitcodeStripInfoTable) {}
+};
+
enum StripID {
STRIP_INVALID = 0, // This is not an option ID.
#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
@@ -432,7 +432,7 @@ template <class T> static ErrorOr<T> getAsInteger(StringRef Val) {
namespace {
-enum class ToolType { Objcopy, Strip, InstallNameTool, BitcodeStrip };
+enum class ToolType { Objcopy, Strip, InstallNameTool, BitcodeStrip };
} // anonymous namespace
@@ -452,10 +452,10 @@ static void printHelp(const opt::OptTable &OptTable, raw_ostream &OS,
ToolName = "llvm-install-name-tool";
HelpText = " [options] input";
break;
- case ToolType::BitcodeStrip:
- ToolName = "llvm-bitcode-strip";
- HelpText = " [options] input";
- break;
+ case ToolType::BitcodeStrip:
+ ToolName = "llvm-bitcode-strip";
+ HelpText = " [options] input";
+ break;
}
OptTable.PrintHelp(OS, (ToolName + HelpText).str().c_str(),
(ToolName + " tool").str().c_str());
@@ -895,9 +895,9 @@ parseInstallNameToolOptions(ArrayRef<const char *> ArgsArr) {
for (auto Arg : InputArgs.filtered(INSTALL_NAME_TOOL_add_rpath))
Config.RPathToAdd.push_back(Arg->getValue());
- for (auto *Arg : InputArgs.filtered(INSTALL_NAME_TOOL_prepend_rpath))
- Config.RPathToPrepend.push_back(Arg->getValue());
-
+ for (auto *Arg : InputArgs.filtered(INSTALL_NAME_TOOL_prepend_rpath))
+ Config.RPathToPrepend.push_back(Arg->getValue());
+
for (auto Arg : InputArgs.filtered(INSTALL_NAME_TOOL_delete_rpath)) {
StringRef RPath = Arg->getValue();
@@ -905,13 +905,13 @@ parseInstallNameToolOptions(ArrayRef<const char *> ArgsArr) {
if (is_contained(Config.RPathToAdd, RPath))
return createStringError(
errc::invalid_argument,
- "cannot specify both -add_rpath '%s' and -delete_rpath '%s'",
- RPath.str().c_str(), RPath.str().c_str());
- if (is_contained(Config.RPathToPrepend, RPath))
- return createStringError(
- errc::invalid_argument,
- "cannot specify both -prepend_rpath '%s' and -delete_rpath '%s'",
+ "cannot specify both -add_rpath '%s' and -delete_rpath '%s'",
RPath.str().c_str(), RPath.str().c_str());
+ if (is_contained(Config.RPathToPrepend, RPath))
+ return createStringError(
+ errc::invalid_argument,
+ "cannot specify both -prepend_rpath '%s' and -delete_rpath '%s'",
+ RPath.str().c_str(), RPath.str().c_str());
Config.RPathsToRemove.insert(RPath);
}
@@ -930,47 +930,47 @@ parseInstallNameToolOptions(ArrayRef<const char *> ArgsArr) {
});
if (It1 != Config.RPathsToUpdate.end())
return createStringError(errc::invalid_argument,
- "cannot specify both -rpath '" +
- It1->getFirst() + "' '" + It1->getSecond() +
- "' and -rpath '" + Old + "' '" + New + "'");
+ "cannot specify both -rpath '" +
+ It1->getFirst() + "' '" + It1->getSecond() +
+ "' and -rpath '" + Old + "' '" + New + "'");
// Cannot specify the same rpath under both -delete_rpath and -rpath
auto It2 = find_if(Config.RPathsToRemove, Match);
if (It2 != Config.RPathsToRemove.end())
return createStringError(errc::invalid_argument,
- "cannot specify both -delete_rpath '" + *It2 +
- "' and -rpath '" + Old + "' '" + New + "'");
+ "cannot specify both -delete_rpath '" + *It2 +
+ "' and -rpath '" + Old + "' '" + New + "'");
// Cannot specify the same rpath under both -add_rpath and -rpath
auto It3 = find_if(Config.RPathToAdd, Match);
if (It3 != Config.RPathToAdd.end())
return createStringError(errc::invalid_argument,
- "cannot specify both -add_rpath '" + *It3 +
- "' and -rpath '" + Old + "' '" + New + "'");
-
- // Cannot specify the same rpath under both -prepend_rpath and -rpath.
- auto It4 = find_if(Config.RPathToPrepend, Match);
- if (It4 != Config.RPathToPrepend.end())
- return createStringError(errc::invalid_argument,
- "cannot specify both -prepend_rpath '" + *It4 +
- "' and -rpath '" + Old + "' '" + New + "'");
-
+ "cannot specify both -add_rpath '" + *It3 +
+ "' and -rpath '" + Old + "' '" + New + "'");
+
+ // Cannot specify the same rpath under both -prepend_rpath and -rpath.
+ auto It4 = find_if(Config.RPathToPrepend, Match);
+ if (It4 != Config.RPathToPrepend.end())
+ return createStringError(errc::invalid_argument,
+ "cannot specify both -prepend_rpath '" + *It4 +
+ "' and -rpath '" + Old + "' '" + New + "'");
+
Config.RPathsToUpdate.insert({Old, New});
}
- if (auto *Arg = InputArgs.getLastArg(INSTALL_NAME_TOOL_id)) {
+ if (auto *Arg = InputArgs.getLastArg(INSTALL_NAME_TOOL_id)) {
Config.SharedLibId = Arg->getValue();
- if (Config.SharedLibId->empty())
- return createStringError(errc::invalid_argument,
- "cannot specify an empty id");
- }
+ if (Config.SharedLibId->empty())
+ return createStringError(errc::invalid_argument,
+ "cannot specify an empty id");
+ }
- for (auto *Arg : InputArgs.filtered(INSTALL_NAME_TOOL_change))
+ for (auto *Arg : InputArgs.filtered(INSTALL_NAME_TOOL_change))
Config.InstallNamesToUpdate.insert({Arg->getValue(0), Arg->getValue(1)});
- Config.RemoveAllRpaths =
- InputArgs.hasArg(INSTALL_NAME_TOOL_delete_all_rpaths);
-
+ Config.RemoveAllRpaths =
+ InputArgs.hasArg(INSTALL_NAME_TOOL_delete_all_rpaths);
+
SmallVector<StringRef, 2> Positional;
for (auto Arg : InputArgs.filtered(INSTALL_NAME_TOOL_UNKNOWN))
return createStringError(errc::invalid_argument, "unknown argument '%s'",
@@ -990,50 +990,50 @@ parseInstallNameToolOptions(ArrayRef<const char *> ArgsArr) {
return std::move(DC);
}
-Expected<DriverConfig>
-parseBitcodeStripOptions(ArrayRef<const char *> ArgsArr) {
- DriverConfig DC;
- CopyConfig Config;
- BitcodeStripOptTable T;
- unsigned MissingArgumentIndex, MissingArgumentCount;
- opt::InputArgList InputArgs =
- T.ParseArgs(ArgsArr, MissingArgumentIndex, MissingArgumentCount);
-
- if (InputArgs.size() == 0) {
- printHelp(T, errs(), ToolType::BitcodeStrip);
- exit(1);
- }
-
- if (InputArgs.hasArg(BITCODE_STRIP_help)) {
- printHelp(T, outs(), ToolType::BitcodeStrip);
- exit(0);
- }
-
- if (InputArgs.hasArg(BITCODE_STRIP_version)) {
- outs() << "llvm-bitcode-strip, compatible with cctools "
- "bitcode_strip\n";
- cl::PrintVersionMessage();
- exit(0);
- }
-
- for (auto *Arg : InputArgs.filtered(BITCODE_STRIP_UNKNOWN))
- return createStringError(errc::invalid_argument, "unknown argument '%s'",
- Arg->getAsString(InputArgs).c_str());
-
- SmallVector<StringRef, 2> Positional;
- for (auto *Arg : InputArgs.filtered(BITCODE_STRIP_INPUT))
- Positional.push_back(Arg->getValue());
- if (Positional.size() > 1)
- return createStringError(errc::invalid_argument,
- "llvm-bitcode-strip expects a single input file");
- assert(!Positional.empty());
- Config.InputFilename = Positional[0];
- Config.OutputFilename = Positional[0];
-
- DC.CopyConfigs.push_back(std::move(Config));
- return std::move(DC);
-}
-
+Expected<DriverConfig>
+parseBitcodeStripOptions(ArrayRef<const char *> ArgsArr) {
+ DriverConfig DC;
+ CopyConfig Config;
+ BitcodeStripOptTable T;
+ unsigned MissingArgumentIndex, MissingArgumentCount;
+ opt::InputArgList InputArgs =
+ T.ParseArgs(ArgsArr, MissingArgumentIndex, MissingArgumentCount);
+
+ if (InputArgs.size() == 0) {
+ printHelp(T, errs(), ToolType::BitcodeStrip);
+ exit(1);
+ }
+
+ if (InputArgs.hasArg(BITCODE_STRIP_help)) {
+ printHelp(T, outs(), ToolType::BitcodeStrip);
+ exit(0);
+ }
+
+ if (InputArgs.hasArg(BITCODE_STRIP_version)) {
+ outs() << "llvm-bitcode-strip, compatible with cctools "
+ "bitcode_strip\n";
+ cl::PrintVersionMessage();
+ exit(0);
+ }
+
+ for (auto *Arg : InputArgs.filtered(BITCODE_STRIP_UNKNOWN))
+ return createStringError(errc::invalid_argument, "unknown argument '%s'",
+ Arg->getAsString(InputArgs).c_str());
+
+ SmallVector<StringRef, 2> Positional;
+ for (auto *Arg : InputArgs.filtered(BITCODE_STRIP_INPUT))
+ Positional.push_back(Arg->getValue());
+ if (Positional.size() > 1)
+ return createStringError(errc::invalid_argument,
+ "llvm-bitcode-strip expects a single input file");
+ assert(!Positional.empty());
+ Config.InputFilename = Positional[0];
+ Config.OutputFilename = Positional[0];
+
+ DC.CopyConfigs.push_back(std::move(Config));
+ return std::move(DC);
+}
+
// ParseStripOptions returns the config and sets the input arguments. If a
// help flag is set then ParseStripOptions will print the help messege and
// exit.
diff --git a/contrib/libs/llvm12/tools/llvm-objcopy/CopyConfig.h b/contrib/libs/llvm12/tools/llvm-objcopy/CopyConfig.h
index 07eac9d2bb..467e1c41f1 100644
--- a/contrib/libs/llvm12/tools/llvm-objcopy/CopyConfig.h
+++ b/contrib/libs/llvm12/tools/llvm-objcopy/CopyConfig.h
@@ -178,7 +178,7 @@ struct CopyConfig {
std::vector<StringRef> DumpSection;
std::vector<StringRef> SymbolsToAdd;
std::vector<StringRef> RPathToAdd;
- std::vector<StringRef> RPathToPrepend;
+ std::vector<StringRef> RPathToPrepend;
DenseMap<StringRef, StringRef> RPathsToUpdate;
DenseMap<StringRef, StringRef> InstallNamesToUpdate;
DenseSet<StringRef> RPathsToRemove;
@@ -231,9 +231,9 @@ struct CopyConfig {
bool StripUnneeded = false;
bool Weaken = false;
bool DecompressDebugSections = false;
- // install-name-tool's --delete_all_rpaths
- bool RemoveAllRpaths = false;
-
+ // install-name-tool's --delete_all_rpaths
+ bool RemoveAllRpaths = false;
+
DebugCompressionType CompressionType = DebugCompressionType::None;
// parseELFConfig performs ELF-specific command-line parsing. Fills `ELF` on
@@ -271,11 +271,11 @@ parseObjcopyOptions(ArrayRef<const char *> ArgsArr,
Expected<DriverConfig>
parseInstallNameToolOptions(ArrayRef<const char *> ArgsArr);
-// ParseBitcodeStripOptions returns the config and sets the input arguments.
-// If a help flag is set then ParseBitcodeStripOptions will print the help
-// messege and exit.
-Expected<DriverConfig> parseBitcodeStripOptions(ArrayRef<const char *> ArgsArr);
-
+// ParseBitcodeStripOptions returns the config and sets the input arguments.
+// If a help flag is set then ParseBitcodeStripOptions will print the help
+// messege and exit.
+Expected<DriverConfig> parseBitcodeStripOptions(ArrayRef<const char *> ArgsArr);
+
// ParseStripOptions returns the config and sets the input arguments. If a
// help flag is set then ParseStripOptions will print the help messege and
// exit. ErrorCallback is used to handle recoverable errors. An Error returned
diff --git a/contrib/libs/llvm12/tools/llvm-objcopy/ELF/ELFObjcopy.cpp b/contrib/libs/llvm12/tools/llvm-objcopy/ELF/ELFObjcopy.cpp
index c53a34bc46..ee808a2d9d 100644
--- a/contrib/libs/llvm12/tools/llvm-objcopy/ELF/ELFObjcopy.cpp
+++ b/contrib/libs/llvm12/tools/llvm-objcopy/ELF/ELFObjcopy.cpp
@@ -184,28 +184,28 @@ findBuildID(const CopyConfig &Config, const object::ELFFile<ELFT> &In) {
return createFileError(Config.InputFilename, std::move(Err));
}
- return createFileError(Config.InputFilename,
- createStringError(llvm::errc::invalid_argument,
- "could not find build ID"));
+ return createFileError(Config.InputFilename,
+ createStringError(llvm::errc::invalid_argument,
+ "could not find build ID"));
}
static Expected<ArrayRef<uint8_t>>
findBuildID(const CopyConfig &Config, const object::ELFObjectFileBase &In) {
if (auto *O = dyn_cast<ELFObjectFile<ELF32LE>>(&In))
- return findBuildID(Config, O->getELFFile());
+ return findBuildID(Config, O->getELFFile());
else if (auto *O = dyn_cast<ELFObjectFile<ELF64LE>>(&In))
- return findBuildID(Config, O->getELFFile());
+ return findBuildID(Config, O->getELFFile());
else if (auto *O = dyn_cast<ELFObjectFile<ELF32BE>>(&In))
- return findBuildID(Config, O->getELFFile());
+ return findBuildID(Config, O->getELFFile());
else if (auto *O = dyn_cast<ELFObjectFile<ELF64BE>>(&In))
- return findBuildID(Config, O->getELFFile());
+ return findBuildID(Config, O->getELFFile());
llvm_unreachable("Bad file format");
}
template <class... Ts>
-static Error makeStringError(std::error_code EC, const Twine &Msg,
- Ts &&... Args) {
+static Error makeStringError(std::error_code EC, const Twine &Msg,
+ Ts &&... Args) {
std::string FullMsg = (EC.message() + ": " + Msg).str();
return createStringError(EC, FullMsg.c_str(), std::forward<Ts>(Args)...);
}
@@ -265,23 +265,23 @@ static Error linkToBuildIdDir(const CopyConfig &Config, StringRef ToLink,
static Error splitDWOToFile(const CopyConfig &Config, const Reader &Reader,
StringRef File, ElfType OutputElfType) {
- Expected<std::unique_ptr<Object>> DWOFile = Reader.create(false);
- if (!DWOFile)
- return DWOFile.takeError();
-
+ Expected<std::unique_ptr<Object>> DWOFile = Reader.create(false);
+ if (!DWOFile)
+ return DWOFile.takeError();
+
auto OnlyKeepDWOPred = [&DWOFile](const SectionBase &Sec) {
- return onlyKeepDWOPred(**DWOFile, Sec);
+ return onlyKeepDWOPred(**DWOFile, Sec);
};
- if (Error E =
- (*DWOFile)->removeSections(Config.AllowBrokenLinks, OnlyKeepDWOPred))
+ if (Error E =
+ (*DWOFile)->removeSections(Config.AllowBrokenLinks, OnlyKeepDWOPred))
return E;
if (Config.OutputArch) {
- (*DWOFile)->Machine = Config.OutputArch.getValue().EMachine;
- (*DWOFile)->OSABI = Config.OutputArch.getValue().OSABI;
+ (*DWOFile)->Machine = Config.OutputArch.getValue().EMachine;
+ (*DWOFile)->OSABI = Config.OutputArch.getValue().OSABI;
}
FileBuffer FB(File);
- std::unique_ptr<Writer> Writer =
- createWriter(Config, **DWOFile, FB, OutputElfType);
+ std::unique_ptr<Writer> Writer =
+ createWriter(Config, **DWOFile, FB, OutputElfType);
if (Error E = Writer->finalize())
return E;
return Writer->write();
@@ -316,39 +316,39 @@ static bool isCompressable(const SectionBase &Sec) {
StringRef(Sec.Name).startswith(".debug");
}
-static Error replaceDebugSections(
+static Error replaceDebugSections(
Object &Obj, SectionPred &RemovePred,
- function_ref<bool(const SectionBase &)> ShouldReplace,
- function_ref<Expected<SectionBase *>(const SectionBase *)> AddSection) {
+ function_ref<bool(const SectionBase &)> ShouldReplace,
+ function_ref<Expected<SectionBase *>(const SectionBase *)> AddSection) {
// Build a list of the debug sections we are going to replace.
- // We can't call `AddSection` while iterating over sections,
+ // We can't call `AddSection` while iterating over sections,
// because it would mutate the sections array.
SmallVector<SectionBase *, 13> ToReplace;
for (auto &Sec : Obj.sections())
- if (ShouldReplace(Sec))
+ if (ShouldReplace(Sec))
ToReplace.push_back(&Sec);
// Build a mapping from original section to a new one.
DenseMap<SectionBase *, SectionBase *> FromTo;
- for (SectionBase *S : ToReplace) {
- Expected<SectionBase *> NewSection = AddSection(S);
- if (!NewSection)
- return NewSection.takeError();
-
- FromTo[S] = *NewSection;
- }
-
+ for (SectionBase *S : ToReplace) {
+ Expected<SectionBase *> NewSection = AddSection(S);
+ if (!NewSection)
+ return NewSection.takeError();
+
+ FromTo[S] = *NewSection;
+ }
+
// Now we want to update the target sections of relocation
// sections. Also we will update the relocations themselves
// to update the symbol references.
for (auto &Sec : Obj.sections())
Sec.replaceSectionReferences(FromTo);
- RemovePred = [ShouldReplace, RemovePred](const SectionBase &Sec) {
- return ShouldReplace(Sec) || RemovePred(Sec);
+ RemovePred = [ShouldReplace, RemovePred](const SectionBase &Sec) {
+ return ShouldReplace(Sec) || RemovePred(Sec);
};
-
- return Error::success();
+
+ return Error::success();
}
static bool isUnneededSymbol(const Symbol &Sym) {
@@ -587,29 +587,29 @@ static Error replaceAndRemoveSections(const CopyConfig &Config, Object &Obj) {
};
}
- if (Config.CompressionType != DebugCompressionType::None) {
- if (Error Err = replaceDebugSections(
- Obj, RemovePred, isCompressable,
- [&Config, &Obj](const SectionBase *S) -> Expected<SectionBase *> {
- Expected<CompressedSection> NewSection =
- CompressedSection::create(*S, Config.CompressionType);
- if (!NewSection)
- return NewSection.takeError();
-
- return &Obj.addSection<CompressedSection>(std::move(*NewSection));
- }))
- return Err;
- } else if (Config.DecompressDebugSections) {
- if (Error Err = replaceDebugSections(
- Obj, RemovePred,
- [](const SectionBase &S) { return isa<CompressedSection>(&S); },
- [&Obj](const SectionBase *S) {
- const CompressedSection *CS = cast<CompressedSection>(S);
- return &Obj.addSection<DecompressedSection>(*CS);
- }))
- return Err;
- }
-
+ if (Config.CompressionType != DebugCompressionType::None) {
+ if (Error Err = replaceDebugSections(
+ Obj, RemovePred, isCompressable,
+ [&Config, &Obj](const SectionBase *S) -> Expected<SectionBase *> {
+ Expected<CompressedSection> NewSection =
+ CompressedSection::create(*S, Config.CompressionType);
+ if (!NewSection)
+ return NewSection.takeError();
+
+ return &Obj.addSection<CompressedSection>(std::move(*NewSection));
+ }))
+ return Err;
+ } else if (Config.DecompressDebugSections) {
+ if (Error Err = replaceDebugSections(
+ Obj, RemovePred,
+ [](const SectionBase &S) { return isa<CompressedSection>(&S); },
+ [&Obj](const SectionBase *S) {
+ const CompressedSection *CS = cast<CompressedSection>(S);
+ return &Obj.addSection<DecompressedSection>(*CS);
+ }))
+ return Err;
+ }
+
return Obj.removeSections(Config.AllowBrokenLinks, RemovePred);
}
@@ -748,9 +748,9 @@ static Error handleArgs(const CopyConfig &Config, Object &Obj,
// If the symbol table was previously removed, we need to create a new one
// before adding new symbols.
- if (!Obj.SymbolTable && !Config.ELF->SymbolsToAdd.empty())
- if (Error E = Obj.addNewSymbolTable())
- return E;
+ if (!Obj.SymbolTable && !Config.ELF->SymbolsToAdd.empty())
+ if (Error E = Obj.addNewSymbolTable())
+ return E;
for (const NewSymbolInfo &SI : Config.ELF->SymbolsToAdd) {
SectionBase *Sec = Obj.findSection(SI.SectionName);
@@ -760,17 +760,17 @@ static Error handleArgs(const CopyConfig &Config, Object &Obj,
Sec ? (uint16_t)SYMBOL_SIMPLE_INDEX : (uint16_t)SHN_ABS, 0);
}
- // --set-section-flags works with sections added by --add-section.
- if (!Config.SetSectionFlags.empty()) {
- for (auto &Sec : Obj.sections()) {
- const auto Iter = Config.SetSectionFlags.find(Sec.Name);
- if (Iter != Config.SetSectionFlags.end()) {
- const SectionFlagsUpdate &SFU = Iter->second;
- setSectionFlagsAndType(Sec, SFU.NewFlags);
- }
- }
- }
-
+ // --set-section-flags works with sections added by --add-section.
+ if (!Config.SetSectionFlags.empty()) {
+ for (auto &Sec : Obj.sections()) {
+ const auto Iter = Config.SetSectionFlags.find(Sec.Name);
+ if (Iter != Config.SetSectionFlags.end()) {
+ const SectionFlagsUpdate &SFU = Iter->second;
+ setSectionFlagsAndType(Sec, SFU.NewFlags);
+ }
+ }
+ }
+
if (Config.EntryExpr)
Obj.Entry = Config.EntryExpr(Obj.Entry);
return Error::success();
@@ -788,15 +788,15 @@ static Error writeOutput(const CopyConfig &Config, Object &Obj, Buffer &Out,
Error executeObjcopyOnIHex(const CopyConfig &Config, MemoryBuffer &In,
Buffer &Out) {
IHexReader Reader(&In);
- Expected<std::unique_ptr<Object>> Obj = Reader.create(true);
- if (!Obj)
- return Obj.takeError();
-
+ Expected<std::unique_ptr<Object>> Obj = Reader.create(true);
+ if (!Obj)
+ return Obj.takeError();
+
const ElfType OutputElfType =
- getOutputElfType(Config.OutputArch.getValueOr(MachineInfo()));
- if (Error E = handleArgs(Config, **Obj, Reader, OutputElfType))
+ getOutputElfType(Config.OutputArch.getValueOr(MachineInfo()));
+ if (Error E = handleArgs(Config, **Obj, Reader, OutputElfType))
return E;
- return writeOutput(Config, **Obj, Out, OutputElfType);
+ return writeOutput(Config, **Obj, Out, OutputElfType);
}
Error executeObjcopyOnRawBinary(const CopyConfig &Config, MemoryBuffer &In,
@@ -804,26 +804,26 @@ Error executeObjcopyOnRawBinary(const CopyConfig &Config, MemoryBuffer &In,
uint8_t NewSymbolVisibility =
Config.ELF->NewSymbolVisibility.getValueOr((uint8_t)ELF::STV_DEFAULT);
BinaryReader Reader(&In, NewSymbolVisibility);
- Expected<std::unique_ptr<Object>> Obj = Reader.create(true);
- if (!Obj)
- return Obj.takeError();
+ Expected<std::unique_ptr<Object>> Obj = Reader.create(true);
+ if (!Obj)
+ return Obj.takeError();
// Prefer OutputArch (-O<format>) if set, otherwise fallback to BinaryArch
// (-B<arch>).
const ElfType OutputElfType =
getOutputElfType(Config.OutputArch.getValueOr(MachineInfo()));
- if (Error E = handleArgs(Config, **Obj, Reader, OutputElfType))
+ if (Error E = handleArgs(Config, **Obj, Reader, OutputElfType))
return E;
- return writeOutput(Config, **Obj, Out, OutputElfType);
+ return writeOutput(Config, **Obj, Out, OutputElfType);
}
Error executeObjcopyOnBinary(const CopyConfig &Config,
object::ELFObjectFileBase &In, Buffer &Out) {
ELFReader Reader(&In, Config.ExtractPartition);
- Expected<std::unique_ptr<Object>> Obj =
- Reader.create(!Config.SymbolsToAdd.empty());
- if (!Obj)
- return Obj.takeError();
+ Expected<std::unique_ptr<Object>> Obj =
+ Reader.create(!Config.SymbolsToAdd.empty());
+ if (!Obj)
+ return Obj.takeError();
// Prefer OutputArch (-O<format>) if set, otherwise infer it from the input.
const ElfType OutputElfType =
Config.OutputArch ? getOutputElfType(Config.OutputArch.getValue())
@@ -849,10 +849,10 @@ Error executeObjcopyOnBinary(const CopyConfig &Config,
Config.BuildIdLinkInput.getValue(), BuildIdBytes))
return E;
- if (Error E = handleArgs(Config, **Obj, Reader, OutputElfType))
+ if (Error E = handleArgs(Config, **Obj, Reader, OutputElfType))
return createFileError(Config.InputFilename, std::move(E));
- if (Error E = writeOutput(Config, **Obj, Out, OutputElfType))
+ if (Error E = writeOutput(Config, **Obj, Out, OutputElfType))
return createFileError(Config.InputFilename, std::move(E));
if (!Config.BuildIdLinkDir.empty() && Config.BuildIdLinkOutput)
if (Error E =
diff --git a/contrib/libs/llvm12/tools/llvm-objcopy/ELF/Object.cpp b/contrib/libs/llvm12/tools/llvm-objcopy/ELF/Object.cpp
index 0ff82f951b..4aea09fb50 100644
--- a/contrib/libs/llvm12/tools/llvm-objcopy/ELF/Object.cpp
+++ b/contrib/libs/llvm12/tools/llvm-objcopy/ELF/Object.cpp
@@ -14,7 +14,7 @@
#include "llvm/ADT/iterator_range.h"
#include "llvm/BinaryFormat/ELF.h"
#include "llvm/MC/MCTargetOptions.h"
-#include "llvm/Object/ELF.h"
+#include "llvm/Object/ELF.h"
#include "llvm/Object/ELFObjectFile.h"
#include "llvm/Support/Compression.h"
#include "llvm/Support/Endian.h"
@@ -51,15 +51,15 @@ template <class ELFT> void ELFWriter<ELFT>::writePhdr(const Segment &Seg) {
}
Error SectionBase::removeSectionReferences(
- bool, function_ref<bool(const SectionBase *)>) {
+ bool, function_ref<bool(const SectionBase *)>) {
return Error::success();
}
-Error SectionBase::removeSymbols(function_ref<bool(const Symbol &)>) {
+Error SectionBase::removeSymbols(function_ref<bool(const Symbol &)>) {
return Error::success();
}
-Error SectionBase::initialize(SectionTableRef) { return Error::success(); }
+Error SectionBase::initialize(SectionTableRef) { return Error::success(); }
void SectionBase::finalize() {}
void SectionBase::markSymbols() {}
void SectionBase::replaceSectionReferences(
@@ -81,98 +81,98 @@ template <class ELFT> void ELFWriter<ELFT>::writeShdr(const SectionBase &Sec) {
Shdr.sh_entsize = Sec.EntrySize;
}
-template <class ELFT> Error ELFSectionSizer<ELFT>::visit(Section &) {
- return Error::success();
-}
+template <class ELFT> Error ELFSectionSizer<ELFT>::visit(Section &) {
+ return Error::success();
+}
-template <class ELFT> Error ELFSectionSizer<ELFT>::visit(OwnedDataSection &) {
- return Error::success();
-}
+template <class ELFT> Error ELFSectionSizer<ELFT>::visit(OwnedDataSection &) {
+ return Error::success();
+}
-template <class ELFT> Error ELFSectionSizer<ELFT>::visit(StringTableSection &) {
- return Error::success();
-}
+template <class ELFT> Error ELFSectionSizer<ELFT>::visit(StringTableSection &) {
+ return Error::success();
+}
template <class ELFT>
-Error ELFSectionSizer<ELFT>::visit(DynamicRelocationSection &) {
- return Error::success();
-}
+Error ELFSectionSizer<ELFT>::visit(DynamicRelocationSection &) {
+ return Error::success();
+}
template <class ELFT>
-Error ELFSectionSizer<ELFT>::visit(SymbolTableSection &Sec) {
+Error ELFSectionSizer<ELFT>::visit(SymbolTableSection &Sec) {
Sec.EntrySize = sizeof(Elf_Sym);
Sec.Size = Sec.Symbols.size() * Sec.EntrySize;
// Align to the largest field in Elf_Sym.
Sec.Align = ELFT::Is64Bits ? sizeof(Elf_Xword) : sizeof(Elf_Word);
- return Error::success();
+ return Error::success();
}
template <class ELFT>
-Error ELFSectionSizer<ELFT>::visit(RelocationSection &Sec) {
+Error ELFSectionSizer<ELFT>::visit(RelocationSection &Sec) {
Sec.EntrySize = Sec.Type == SHT_REL ? sizeof(Elf_Rel) : sizeof(Elf_Rela);
Sec.Size = Sec.Relocations.size() * Sec.EntrySize;
// Align to the largest field in Elf_Rel(a).
Sec.Align = ELFT::Is64Bits ? sizeof(Elf_Xword) : sizeof(Elf_Word);
- return Error::success();
+ return Error::success();
}
template <class ELFT>
-Error ELFSectionSizer<ELFT>::visit(GnuDebugLinkSection &) {
- return Error::success();
-}
+Error ELFSectionSizer<ELFT>::visit(GnuDebugLinkSection &) {
+ return Error::success();
+}
-template <class ELFT> Error ELFSectionSizer<ELFT>::visit(GroupSection &Sec) {
+template <class ELFT> Error ELFSectionSizer<ELFT>::visit(GroupSection &Sec) {
Sec.Size = sizeof(Elf_Word) + Sec.GroupMembers.size() * sizeof(Elf_Word);
- return Error::success();
+ return Error::success();
}
template <class ELFT>
-Error ELFSectionSizer<ELFT>::visit(SectionIndexSection &) {
- return Error::success();
-}
+Error ELFSectionSizer<ELFT>::visit(SectionIndexSection &) {
+ return Error::success();
+}
-template <class ELFT> Error ELFSectionSizer<ELFT>::visit(CompressedSection &) {
- return Error::success();
-}
+template <class ELFT> Error ELFSectionSizer<ELFT>::visit(CompressedSection &) {
+ return Error::success();
+}
template <class ELFT>
-Error ELFSectionSizer<ELFT>::visit(DecompressedSection &) {
- return Error::success();
-}
+Error ELFSectionSizer<ELFT>::visit(DecompressedSection &) {
+ return Error::success();
+}
-Error BinarySectionWriter::visit(const SectionIndexSection &Sec) {
- return createStringError(errc::operation_not_permitted,
- "cannot write symbol section index table '" +
- Sec.Name + "' ");
+Error BinarySectionWriter::visit(const SectionIndexSection &Sec) {
+ return createStringError(errc::operation_not_permitted,
+ "cannot write symbol section index table '" +
+ Sec.Name + "' ");
}
-Error BinarySectionWriter::visit(const SymbolTableSection &Sec) {
- return createStringError(errc::operation_not_permitted,
- "cannot write symbol table '" + Sec.Name +
- "' out to binary");
+Error BinarySectionWriter::visit(const SymbolTableSection &Sec) {
+ return createStringError(errc::operation_not_permitted,
+ "cannot write symbol table '" + Sec.Name +
+ "' out to binary");
}
-Error BinarySectionWriter::visit(const RelocationSection &Sec) {
- return createStringError(errc::operation_not_permitted,
- "cannot write relocation section '" + Sec.Name +
- "' out to binary");
+Error BinarySectionWriter::visit(const RelocationSection &Sec) {
+ return createStringError(errc::operation_not_permitted,
+ "cannot write relocation section '" + Sec.Name +
+ "' out to binary");
}
-Error BinarySectionWriter::visit(const GnuDebugLinkSection &Sec) {
- return createStringError(errc::operation_not_permitted,
- "cannot write '" + Sec.Name + "' out to binary");
+Error BinarySectionWriter::visit(const GnuDebugLinkSection &Sec) {
+ return createStringError(errc::operation_not_permitted,
+ "cannot write '" + Sec.Name + "' out to binary");
}
-Error BinarySectionWriter::visit(const GroupSection &Sec) {
- return createStringError(errc::operation_not_permitted,
- "cannot write '" + Sec.Name + "' out to binary");
+Error BinarySectionWriter::visit(const GroupSection &Sec) {
+ return createStringError(errc::operation_not_permitted,
+ "cannot write '" + Sec.Name + "' out to binary");
}
-Error SectionWriter::visit(const Section &Sec) {
+Error SectionWriter::visit(const Section &Sec) {
if (Sec.Type != SHT_NOBITS)
llvm::copy(Sec.Contents, Out.getBufferStart() + Sec.Offset);
-
- return Error::success();
+
+ return Error::success();
}
static bool addressOverflows32bit(uint64_t Addr) {
@@ -377,34 +377,34 @@ uint64_t IHexSectionWriterBase::writeBaseAddr(uint64_t Addr) {
return Base;
}
-void IHexSectionWriterBase::writeData(uint8_t, uint16_t,
+void IHexSectionWriterBase::writeData(uint8_t, uint16_t,
ArrayRef<uint8_t> Data) {
Offset += IHexRecord::getLineLength(Data.size());
}
-Error IHexSectionWriterBase::visit(const Section &Sec) {
+Error IHexSectionWriterBase::visit(const Section &Sec) {
writeSection(&Sec, Sec.Contents);
- return Error::success();
+ return Error::success();
}
-Error IHexSectionWriterBase::visit(const OwnedDataSection &Sec) {
+Error IHexSectionWriterBase::visit(const OwnedDataSection &Sec) {
writeSection(&Sec, Sec.Data);
- return Error::success();
+ return Error::success();
}
-Error IHexSectionWriterBase::visit(const StringTableSection &Sec) {
+Error IHexSectionWriterBase::visit(const StringTableSection &Sec) {
// Check that sizer has already done its work
assert(Sec.Size == Sec.StrTabBuilder.getSize());
// We are free to pass an invalid pointer to writeSection as long
// as we don't actually write any data. The real writer class has
// to override this method .
writeSection(&Sec, {nullptr, static_cast<size_t>(Sec.Size)});
- return Error::success();
+ return Error::success();
}
-Error IHexSectionWriterBase::visit(const DynamicRelocationSection &Sec) {
+Error IHexSectionWriterBase::visit(const DynamicRelocationSection &Sec) {
writeSection(&Sec, Sec.Contents);
- return Error::success();
+ return Error::success();
}
void IHexSectionWriter::writeData(uint8_t Type, uint16_t Addr,
@@ -414,25 +414,25 @@ void IHexSectionWriter::writeData(uint8_t Type, uint16_t Addr,
Offset += HexData.size();
}
-Error IHexSectionWriter::visit(const StringTableSection &Sec) {
+Error IHexSectionWriter::visit(const StringTableSection &Sec) {
assert(Sec.Size == Sec.StrTabBuilder.getSize());
std::vector<uint8_t> Data(Sec.Size);
Sec.StrTabBuilder.write(Data.data());
writeSection(&Sec, Data);
- return Error::success();
+ return Error::success();
}
-Error Section::accept(SectionVisitor &Visitor) const {
- return Visitor.visit(*this);
-}
+Error Section::accept(SectionVisitor &Visitor) const {
+ return Visitor.visit(*this);
+}
-Error Section::accept(MutableSectionVisitor &Visitor) {
- return Visitor.visit(*this);
-}
+Error Section::accept(MutableSectionVisitor &Visitor) {
+ return Visitor.visit(*this);
+}
-Error SectionWriter::visit(const OwnedDataSection &Sec) {
+Error SectionWriter::visit(const OwnedDataSection &Sec) {
llvm::copy(Sec.Data, Out.getBufferStart() + Sec.Offset);
- return Error::success();
+ return Error::success();
}
static constexpr std::array<uint8_t, 4> ZlibGnuMagic = {{'Z', 'L', 'I', 'B'}};
@@ -459,7 +459,7 @@ getDecompressedSizeAndAlignment(ArrayRef<uint8_t> Data) {
}
template <class ELFT>
-Error ELFSectionWriter<ELFT>::visit(const DecompressedSection &Sec) {
+Error ELFSectionWriter<ELFT>::visit(const DecompressedSection &Sec) {
const size_t DataOffset = isDataGnuCompressed(Sec.OriginalData)
? (ZlibGnuMagic.size() + sizeof(Sec.Size))
: sizeof(Elf_Chdr_Impl<ELFT>);
@@ -469,37 +469,37 @@ Error ELFSectionWriter<ELFT>::visit(const DecompressedSection &Sec) {
Sec.OriginalData.size() - DataOffset);
SmallVector<char, 128> DecompressedContent;
- if (Error Err = zlib::uncompress(CompressedContent, DecompressedContent,
- static_cast<size_t>(Sec.Size)))
- return createStringError(errc::invalid_argument,
- "'" + Sec.Name + "': " + toString(std::move(Err)));
+ if (Error Err = zlib::uncompress(CompressedContent, DecompressedContent,
+ static_cast<size_t>(Sec.Size)))
+ return createStringError(errc::invalid_argument,
+ "'" + Sec.Name + "': " + toString(std::move(Err)));
uint8_t *Buf = Out.getBufferStart() + Sec.Offset;
std::copy(DecompressedContent.begin(), DecompressedContent.end(), Buf);
-
- return Error::success();
+
+ return Error::success();
}
-Error BinarySectionWriter::visit(const DecompressedSection &Sec) {
- return createStringError(errc::operation_not_permitted,
- "cannot write compressed section '" + Sec.Name +
- "' ");
+Error BinarySectionWriter::visit(const DecompressedSection &Sec) {
+ return createStringError(errc::operation_not_permitted,
+ "cannot write compressed section '" + Sec.Name +
+ "' ");
}
-Error DecompressedSection::accept(SectionVisitor &Visitor) const {
- return Visitor.visit(*this);
+Error DecompressedSection::accept(SectionVisitor &Visitor) const {
+ return Visitor.visit(*this);
}
-Error DecompressedSection::accept(MutableSectionVisitor &Visitor) {
- return Visitor.visit(*this);
+Error DecompressedSection::accept(MutableSectionVisitor &Visitor) {
+ return Visitor.visit(*this);
}
-Error OwnedDataSection::accept(SectionVisitor &Visitor) const {
- return Visitor.visit(*this);
+Error OwnedDataSection::accept(SectionVisitor &Visitor) const {
+ return Visitor.visit(*this);
}
-Error OwnedDataSection::accept(MutableSectionVisitor &Visitor) {
- return Visitor.visit(*this);
+Error OwnedDataSection::accept(MutableSectionVisitor &Visitor) {
+ return Visitor.visit(*this);
}
void OwnedDataSection::appendHexData(StringRef HexData) {
@@ -511,18 +511,18 @@ void OwnedDataSection::appendHexData(StringRef HexData) {
Size = Data.size();
}
-Error BinarySectionWriter::visit(const CompressedSection &Sec) {
- return createStringError(errc::operation_not_permitted,
- "cannot write compressed section '" + Sec.Name +
- "' ");
+Error BinarySectionWriter::visit(const CompressedSection &Sec) {
+ return createStringError(errc::operation_not_permitted,
+ "cannot write compressed section '" + Sec.Name +
+ "' ");
}
template <class ELFT>
-Error ELFSectionWriter<ELFT>::visit(const CompressedSection &Sec) {
+Error ELFSectionWriter<ELFT>::visit(const CompressedSection &Sec) {
uint8_t *Buf = Out.getBufferStart() + Sec.Offset;
if (Sec.CompressionType == DebugCompressionType::None) {
std::copy(Sec.OriginalData.begin(), Sec.OriginalData.end(), Buf);
- return Error::success();
+ return Error::success();
}
if (Sec.CompressionType == DebugCompressionType::GNU) {
@@ -543,42 +543,42 @@ Error ELFSectionWriter<ELFT>::visit(const CompressedSection &Sec) {
}
std::copy(Sec.CompressedData.begin(), Sec.CompressedData.end(), Buf);
- return Error::success();
-}
-
-Expected<CompressedSection>
-CompressedSection::create(const SectionBase &Sec,
- DebugCompressionType CompressionType) {
- Error Err = Error::success();
- CompressedSection Section(Sec, CompressionType, Err);
-
- if (Err)
- return std::move(Err);
-
- return Section;
-}
-Expected<CompressedSection>
-CompressedSection::create(ArrayRef<uint8_t> CompressedData,
- uint64_t DecompressedSize,
- uint64_t DecompressedAlign) {
- return CompressedSection(CompressedData, DecompressedSize, DecompressedAlign);
-}
-
+ return Error::success();
+}
+
+Expected<CompressedSection>
+CompressedSection::create(const SectionBase &Sec,
+ DebugCompressionType CompressionType) {
+ Error Err = Error::success();
+ CompressedSection Section(Sec, CompressionType, Err);
+
+ if (Err)
+ return std::move(Err);
+
+ return Section;
+}
+Expected<CompressedSection>
+CompressedSection::create(ArrayRef<uint8_t> CompressedData,
+ uint64_t DecompressedSize,
+ uint64_t DecompressedAlign) {
+ return CompressedSection(CompressedData, DecompressedSize, DecompressedAlign);
+}
+
CompressedSection::CompressedSection(const SectionBase &Sec,
- DebugCompressionType CompressionType,
- Error &OutErr)
+ DebugCompressionType CompressionType,
+ Error &OutErr)
: SectionBase(Sec), CompressionType(CompressionType),
DecompressedSize(Sec.OriginalData.size()), DecompressedAlign(Sec.Align) {
- ErrorAsOutParameter EAO(&OutErr);
-
- if (Error Err = zlib::compress(
+ ErrorAsOutParameter EAO(&OutErr);
+
+ if (Error Err = zlib::compress(
StringRef(reinterpret_cast<const char *>(OriginalData.data()),
OriginalData.size()),
- CompressedData)) {
- OutErr = createStringError(llvm::errc::invalid_argument,
- "'" + Name + "': " + toString(std::move(Err)));
- return;
- }
+ CompressedData)) {
+ OutErr = createStringError(llvm::errc::invalid_argument,
+ "'" + Name + "': " + toString(std::move(Err)));
+ return;
+ }
size_t ChdrSize;
if (CompressionType == DebugCompressionType::GNU) {
@@ -604,12 +604,12 @@ CompressedSection::CompressedSection(ArrayRef<uint8_t> CompressedData,
OriginalData = CompressedData;
}
-Error CompressedSection::accept(SectionVisitor &Visitor) const {
- return Visitor.visit(*this);
+Error CompressedSection::accept(SectionVisitor &Visitor) const {
+ return Visitor.visit(*this);
}
-Error CompressedSection::accept(MutableSectionVisitor &Visitor) {
- return Visitor.visit(*this);
+Error CompressedSection::accept(MutableSectionVisitor &Visitor) {
+ return Visitor.visit(*this);
}
void StringTableSection::addString(StringRef Name) { StrTabBuilder.add(Name); }
@@ -623,51 +623,51 @@ void StringTableSection::prepareForLayout() {
Size = StrTabBuilder.getSize();
}
-Error SectionWriter::visit(const StringTableSection &Sec) {
+Error SectionWriter::visit(const StringTableSection &Sec) {
Sec.StrTabBuilder.write(Out.getBufferStart() + Sec.Offset);
- return Error::success();
+ return Error::success();
}
-Error StringTableSection::accept(SectionVisitor &Visitor) const {
- return Visitor.visit(*this);
+Error StringTableSection::accept(SectionVisitor &Visitor) const {
+ return Visitor.visit(*this);
}
-Error StringTableSection::accept(MutableSectionVisitor &Visitor) {
- return Visitor.visit(*this);
+Error StringTableSection::accept(MutableSectionVisitor &Visitor) {
+ return Visitor.visit(*this);
}
template <class ELFT>
-Error ELFSectionWriter<ELFT>::visit(const SectionIndexSection &Sec) {
+Error ELFSectionWriter<ELFT>::visit(const SectionIndexSection &Sec) {
uint8_t *Buf = Out.getBufferStart() + Sec.Offset;
llvm::copy(Sec.Indexes, reinterpret_cast<Elf_Word *>(Buf));
- return Error::success();
+ return Error::success();
}
-Error SectionIndexSection::initialize(SectionTableRef SecTable) {
+Error SectionIndexSection::initialize(SectionTableRef SecTable) {
Size = 0;
- Expected<SymbolTableSection *> Sec =
- SecTable.getSectionOfType<SymbolTableSection>(
- Link,
- "Link field value " + Twine(Link) + " in section " + Name +
- " is invalid",
- "Link field value " + Twine(Link) + " in section " + Name +
- " is not a symbol table");
- if (!Sec)
- return Sec.takeError();
-
- setSymTab(*Sec);
+ Expected<SymbolTableSection *> Sec =
+ SecTable.getSectionOfType<SymbolTableSection>(
+ Link,
+ "Link field value " + Twine(Link) + " in section " + Name +
+ " is invalid",
+ "Link field value " + Twine(Link) + " in section " + Name +
+ " is not a symbol table");
+ if (!Sec)
+ return Sec.takeError();
+
+ setSymTab(*Sec);
Symbols->setShndxTable(this);
- return Error::success();
+ return Error::success();
}
void SectionIndexSection::finalize() { Link = Symbols->Index; }
-Error SectionIndexSection::accept(SectionVisitor &Visitor) const {
- return Visitor.visit(*this);
+Error SectionIndexSection::accept(SectionVisitor &Visitor) const {
+ return Visitor.visit(*this);
}
-Error SectionIndexSection::accept(MutableSectionVisitor &Visitor) {
- return Visitor.visit(*this);
+Error SectionIndexSection::accept(MutableSectionVisitor &Visitor) {
+ return Visitor.visit(*this);
}
static bool isValidReservedSectionIndex(uint16_t Index, uint16_t Machine) {
@@ -750,7 +750,7 @@ void SymbolTableSection::addSymbol(Twine Name, uint8_t Bind, uint8_t Type,
}
Error SymbolTableSection::removeSectionReferences(
- bool AllowBrokenLinks, function_ref<bool(const SectionBase *)> ToRemove) {
+ bool AllowBrokenLinks, function_ref<bool(const SectionBase *)> ToRemove) {
if (ToRemove(SectionIndexTable))
SectionIndexTable = nullptr;
if (ToRemove(SymbolNames)) {
@@ -793,20 +793,20 @@ void SymbolTableSection::replaceSectionReferences(
Sym->DefinedIn = To;
}
-Error SymbolTableSection::initialize(SectionTableRef SecTable) {
+Error SymbolTableSection::initialize(SectionTableRef SecTable) {
Size = 0;
- Expected<StringTableSection *> Sec =
- SecTable.getSectionOfType<StringTableSection>(
- Link,
- "Symbol table has link index of " + Twine(Link) +
- " which is not a valid index",
- "Symbol table has link index of " + Twine(Link) +
- " which is not a string table");
- if (!Sec)
- return Sec.takeError();
-
- setStrTab(*Sec);
- return Error::success();
+ Expected<StringTableSection *> Sec =
+ SecTable.getSectionOfType<StringTableSection>(
+ Link,
+ "Symbol table has link index of " + Twine(Link) +
+ " which is not a valid index",
+ "Symbol table has link index of " + Twine(Link) +
+ " which is not a string table");
+ if (!Sec)
+ return Sec.takeError();
+
+ setStrTab(*Sec);
+ return Error::success();
}
void SymbolTableSection::finalize() {
@@ -851,25 +851,25 @@ void SymbolTableSection::fillShndxTable() {
}
}
-Expected<const Symbol *>
-SymbolTableSection::getSymbolByIndex(uint32_t Index) const {
+Expected<const Symbol *>
+SymbolTableSection::getSymbolByIndex(uint32_t Index) const {
if (Symbols.size() <= Index)
- return createStringError(errc::invalid_argument,
- "invalid symbol index: " + Twine(Index));
+ return createStringError(errc::invalid_argument,
+ "invalid symbol index: " + Twine(Index));
return Symbols[Index].get();
}
-Expected<Symbol *> SymbolTableSection::getSymbolByIndex(uint32_t Index) {
- Expected<const Symbol *> Sym =
- static_cast<const SymbolTableSection *>(this)->getSymbolByIndex(Index);
- if (!Sym)
- return Sym.takeError();
-
- return const_cast<Symbol *>(*Sym);
+Expected<Symbol *> SymbolTableSection::getSymbolByIndex(uint32_t Index) {
+ Expected<const Symbol *> Sym =
+ static_cast<const SymbolTableSection *>(this)->getSymbolByIndex(Index);
+ if (!Sym)
+ return Sym.takeError();
+
+ return const_cast<Symbol *>(*Sym);
}
template <class ELFT>
-Error ELFSectionWriter<ELFT>::visit(const SymbolTableSection &Sec) {
+Error ELFSectionWriter<ELFT>::visit(const SymbolTableSection &Sec) {
Elf_Sym *Sym = reinterpret_cast<Elf_Sym *>(Out.getBufferStart() + Sec.Offset);
// Loop though symbols setting each entry of the symbol table.
for (const std::unique_ptr<Symbol> &Symbol : Sec.Symbols) {
@@ -882,19 +882,19 @@ Error ELFSectionWriter<ELFT>::visit(const SymbolTableSection &Sec) {
Sym->st_shndx = Symbol->getShndx();
++Sym;
}
- return Error::success();
+ return Error::success();
}
-Error SymbolTableSection::accept(SectionVisitor &Visitor) const {
- return Visitor.visit(*this);
+Error SymbolTableSection::accept(SectionVisitor &Visitor) const {
+ return Visitor.visit(*this);
}
-Error SymbolTableSection::accept(MutableSectionVisitor &Visitor) {
- return Visitor.visit(*this);
+Error SymbolTableSection::accept(MutableSectionVisitor &Visitor) {
+ return Visitor.visit(*this);
}
Error RelocationSection::removeSectionReferences(
- bool AllowBrokenLinks, function_ref<bool(const SectionBase *)> ToRemove) {
+ bool AllowBrokenLinks, function_ref<bool(const SectionBase *)> ToRemove) {
if (ToRemove(Symbols)) {
if (!AllowBrokenLinks)
return createStringError(
@@ -921,33 +921,33 @@ Error RelocationSection::removeSectionReferences(
}
template <class SymTabType>
-Error RelocSectionWithSymtabBase<SymTabType>::initialize(
+Error RelocSectionWithSymtabBase<SymTabType>::initialize(
SectionTableRef SecTable) {
- if (Link != SHN_UNDEF) {
- Expected<SymTabType *> Sec = SecTable.getSectionOfType<SymTabType>(
+ if (Link != SHN_UNDEF) {
+ Expected<SymTabType *> Sec = SecTable.getSectionOfType<SymTabType>(
Link,
"Link field value " + Twine(Link) + " in section " + Name +
" is invalid",
"Link field value " + Twine(Link) + " in section " + Name +
- " is not a symbol table");
- if (!Sec)
- return Sec.takeError();
-
- setSymTab(*Sec);
- }
-
- if (Info != SHN_UNDEF) {
- Expected<SectionBase *> Sec =
- SecTable.getSection(Info, "Info field value " + Twine(Info) +
- " in section " + Name + " is invalid");
- if (!Sec)
- return Sec.takeError();
-
- setSection(*Sec);
- } else
+ " is not a symbol table");
+ if (!Sec)
+ return Sec.takeError();
+
+ setSymTab(*Sec);
+ }
+
+ if (Info != SHN_UNDEF) {
+ Expected<SectionBase *> Sec =
+ SecTable.getSection(Info, "Info field value " + Twine(Info) +
+ " in section " + Name + " is invalid");
+ if (!Sec)
+ return Sec.takeError();
+
+ setSection(*Sec);
+ } else
setSection(nullptr);
-
- return Error::success();
+
+ return Error::success();
}
template <class SymTabType>
@@ -959,7 +959,7 @@ void RelocSectionWithSymtabBase<SymTabType>::finalize() {
}
template <class ELFT>
-static void setAddend(Elf_Rel_Impl<ELFT, false> &, uint64_t) {}
+static void setAddend(Elf_Rel_Impl<ELFT, false> &, uint64_t) {}
template <class ELFT>
static void setAddend(Elf_Rel_Impl<ELFT, true> &Rela, uint64_t Addend) {
@@ -978,21 +978,21 @@ static void writeRel(const RelRange &Relocations, T *Buf) {
}
template <class ELFT>
-Error ELFSectionWriter<ELFT>::visit(const RelocationSection &Sec) {
+Error ELFSectionWriter<ELFT>::visit(const RelocationSection &Sec) {
uint8_t *Buf = Out.getBufferStart() + Sec.Offset;
if (Sec.Type == SHT_REL)
writeRel(Sec.Relocations, reinterpret_cast<Elf_Rel *>(Buf));
else
writeRel(Sec.Relocations, reinterpret_cast<Elf_Rela *>(Buf));
- return Error::success();
+ return Error::success();
}
-Error RelocationSection::accept(SectionVisitor &Visitor) const {
- return Visitor.visit(*this);
+Error RelocationSection::accept(SectionVisitor &Visitor) const {
+ return Visitor.visit(*this);
}
-Error RelocationSection::accept(MutableSectionVisitor &Visitor) {
- return Visitor.visit(*this);
+Error RelocationSection::accept(MutableSectionVisitor &Visitor) {
+ return Visitor.visit(*this);
}
Error RelocationSection::removeSymbols(
@@ -1019,17 +1019,17 @@ void RelocationSection::replaceSectionReferences(
SecToApplyRel = To;
}
-Error SectionWriter::visit(const DynamicRelocationSection &Sec) {
+Error SectionWriter::visit(const DynamicRelocationSection &Sec) {
llvm::copy(Sec.Contents, Out.getBufferStart() + Sec.Offset);
- return Error::success();
+ return Error::success();
}
-Error DynamicRelocationSection::accept(SectionVisitor &Visitor) const {
- return Visitor.visit(*this);
+Error DynamicRelocationSection::accept(SectionVisitor &Visitor) const {
+ return Visitor.visit(*this);
}
-Error DynamicRelocationSection::accept(MutableSectionVisitor &Visitor) {
- return Visitor.visit(*this);
+Error DynamicRelocationSection::accept(MutableSectionVisitor &Visitor) {
+ return Visitor.visit(*this);
}
Error DynamicRelocationSection::removeSectionReferences(
@@ -1115,22 +1115,22 @@ void GroupSection::onRemove() {
Sec->Flags &= ~SHF_GROUP;
}
-Error Section::initialize(SectionTableRef SecTable) {
+Error Section::initialize(SectionTableRef SecTable) {
if (Link == ELF::SHN_UNDEF)
- return Error::success();
-
- Expected<SectionBase *> Sec =
+ return Error::success();
+
+ Expected<SectionBase *> Sec =
SecTable.getSection(Link, "Link field value " + Twine(Link) +
" in section " + Name + " is invalid");
- if (!Sec)
- return Sec.takeError();
-
- LinkSection = *Sec;
-
+ if (!Sec)
+ return Sec.takeError();
+
+ LinkSection = *Sec;
+
if (LinkSection->Type == ELF::SHT_SYMTAB)
LinkSection = nullptr;
-
- return Error::success();
+
+ return Error::success();
}
void Section::finalize() { this->Link = LinkSection ? LinkSection->Index : 0; }
@@ -1159,39 +1159,39 @@ GnuDebugLinkSection::GnuDebugLinkSection(StringRef File,
}
template <class ELFT>
-Error ELFSectionWriter<ELFT>::visit(const GnuDebugLinkSection &Sec) {
+Error ELFSectionWriter<ELFT>::visit(const GnuDebugLinkSection &Sec) {
unsigned char *Buf = Out.getBufferStart() + Sec.Offset;
Elf_Word *CRC =
reinterpret_cast<Elf_Word *>(Buf + Sec.Size - sizeof(Elf_Word));
*CRC = Sec.CRC32;
llvm::copy(Sec.FileName, Buf);
- return Error::success();
+ return Error::success();
}
-Error GnuDebugLinkSection::accept(SectionVisitor &Visitor) const {
- return Visitor.visit(*this);
+Error GnuDebugLinkSection::accept(SectionVisitor &Visitor) const {
+ return Visitor.visit(*this);
}
-Error GnuDebugLinkSection::accept(MutableSectionVisitor &Visitor) {
- return Visitor.visit(*this);
+Error GnuDebugLinkSection::accept(MutableSectionVisitor &Visitor) {
+ return Visitor.visit(*this);
}
template <class ELFT>
-Error ELFSectionWriter<ELFT>::visit(const GroupSection &Sec) {
+Error ELFSectionWriter<ELFT>::visit(const GroupSection &Sec) {
ELF::Elf32_Word *Buf =
reinterpret_cast<ELF::Elf32_Word *>(Out.getBufferStart() + Sec.Offset);
*Buf++ = Sec.FlagWord;
for (SectionBase *S : Sec.GroupMembers)
support::endian::write32<ELFT::TargetEndianness>(Buf++, S->Index);
- return Error::success();
+ return Error::success();
}
-Error GroupSection::accept(SectionVisitor &Visitor) const {
- return Visitor.visit(*this);
+Error GroupSection::accept(SectionVisitor &Visitor) const {
+ return Visitor.visit(*this);
}
-Error GroupSection::accept(MutableSectionVisitor &Visitor) {
- return Visitor.visit(*this);
+Error GroupSection::accept(MutableSectionVisitor &Visitor) {
+ return Visitor.visit(*this);
}
// Returns true IFF a section is wholly inside the range of a segment
@@ -1271,12 +1271,12 @@ SymbolTableSection *BasicELFBuilder::addSymTab(StringTableSection *StrTab) {
return &SymTab;
}
-Error BasicELFBuilder::initSections() {
+Error BasicELFBuilder::initSections() {
for (SectionBase &Sec : Obj->sections())
- if (Error Err = Sec.initialize(Obj->sections()))
- return Err;
-
- return Error::success();
+ if (Error Err = Sec.initialize(Obj->sections()))
+ return Err;
+
+ return Error::success();
}
void BinaryELFBuilder::addData(SymbolTableSection *SymTab) {
@@ -1303,13 +1303,13 @@ void BinaryELFBuilder::addData(SymbolTableSection *SymTab) {
0);
}
-Expected<std::unique_ptr<Object>> BinaryELFBuilder::build() {
+Expected<std::unique_ptr<Object>> BinaryELFBuilder::build() {
initFileHeader();
initHeaderSegment();
SymbolTableSection *SymTab = addSymTab(addStrTab());
- if (Error Err = initSections())
- return std::move(Err);
+ if (Error Err = initSections())
+ return std::move(Err);
addData(SymTab);
return std::move(Obj);
@@ -1360,13 +1360,13 @@ void IHexELFBuilder::addDataSections() {
}
}
-Expected<std::unique_ptr<Object>> IHexELFBuilder::build() {
+Expected<std::unique_ptr<Object>> IHexELFBuilder::build() {
initFileHeader();
initHeaderSegment();
StringTableSection *StrTab = addStrTab();
addSymTab(StrTab);
- if (Error Err = initSections())
- return std::move(Err);
+ if (Error Err = initSections())
+ return std::move(Err);
addDataSections();
return std::move(Obj);
@@ -1388,37 +1388,37 @@ template <class ELFT> void ELFBuilder<ELFT>::setParentSegment(Segment &Child) {
}
}
-template <class ELFT> Error ELFBuilder<ELFT>::findEhdrOffset() {
+template <class ELFT> Error ELFBuilder<ELFT>::findEhdrOffset() {
if (!ExtractPartition)
- return Error::success();
+ return Error::success();
for (const SectionBase &Sec : Obj.sections()) {
if (Sec.Type == SHT_LLVM_PART_EHDR && Sec.Name == *ExtractPartition) {
EhdrOffset = Sec.Offset;
- return Error::success();
+ return Error::success();
}
}
- return createStringError(errc::invalid_argument,
- "could not find partition named '" +
- *ExtractPartition + "'");
+ return createStringError(errc::invalid_argument,
+ "could not find partition named '" +
+ *ExtractPartition + "'");
}
template <class ELFT>
-Error ELFBuilder<ELFT>::readProgramHeaders(const ELFFile<ELFT> &HeadersFile) {
+Error ELFBuilder<ELFT>::readProgramHeaders(const ELFFile<ELFT> &HeadersFile) {
uint32_t Index = 0;
-
- Expected<typename ELFFile<ELFT>::Elf_Phdr_Range> Headers =
- HeadersFile.program_headers();
- if (!Headers)
- return Headers.takeError();
-
- for (const typename ELFFile<ELFT>::Elf_Phdr &Phdr : *Headers) {
+
+ Expected<typename ELFFile<ELFT>::Elf_Phdr_Range> Headers =
+ HeadersFile.program_headers();
+ if (!Headers)
+ return Headers.takeError();
+
+ for (const typename ELFFile<ELFT>::Elf_Phdr &Phdr : *Headers) {
if (Phdr.p_offset + Phdr.p_filesz > HeadersFile.getBufSize())
- return createStringError(
- errc::invalid_argument,
- "program header with offset 0x" + Twine::utohexstr(Phdr.p_offset) +
- " and file size 0x" + Twine::utohexstr(Phdr.p_filesz) +
- " goes past the end of the file");
+ return createStringError(
+ errc::invalid_argument,
+ "program header with offset 0x" + Twine::utohexstr(Phdr.p_offset) +
+ " and file size 0x" + Twine::utohexstr(Phdr.p_filesz) +
+ " goes past the end of the file");
ArrayRef<uint8_t> Data{HeadersFile.base() + Phdr.p_offset,
(size_t)Phdr.p_filesz};
@@ -1445,7 +1445,7 @@ Error ELFBuilder<ELFT>::readProgramHeaders(const ELFFile<ELFT> &HeadersFile) {
ElfHdr.Index = Index++;
ElfHdr.OriginalOffset = ElfHdr.Offset = EhdrOffset;
- const typename ELFT::Ehdr &Ehdr = HeadersFile.getHeader();
+ const typename ELFT::Ehdr &Ehdr = HeadersFile.getHeader();
auto &PrHdr = Obj.ProgramHdrSegment;
PrHdr.Type = PT_PHDR;
PrHdr.Flags = 0;
@@ -1466,16 +1466,16 @@ Error ELFBuilder<ELFT>::readProgramHeaders(const ELFFile<ELFT> &HeadersFile) {
setParentSegment(Child);
setParentSegment(ElfHdr);
setParentSegment(PrHdr);
-
- return Error::success();
+
+ return Error::success();
}
template <class ELFT>
-Error ELFBuilder<ELFT>::initGroupSection(GroupSection *GroupSec) {
+Error ELFBuilder<ELFT>::initGroupSection(GroupSection *GroupSec) {
if (GroupSec->Align % sizeof(ELF::Elf32_Word) != 0)
- return createStringError(errc::invalid_argument,
- "invalid alignment " + Twine(GroupSec->Align) +
- " of group section '" + GroupSec->Name + "'");
+ return createStringError(errc::invalid_argument,
+ "invalid alignment " + Twine(GroupSec->Align) +
+ " of group section '" + GroupSec->Name + "'");
SectionTableRef SecTable = Obj.sections();
if (GroupSec->Link != SHN_UNDEF) {
auto SymTab = SecTable.template getSectionOfType<SymbolTableSection>(
@@ -1484,23 +1484,23 @@ Error ELFBuilder<ELFT>::initGroupSection(GroupSection *GroupSec) {
GroupSec->Name + "' is invalid",
"link field value '" + Twine(GroupSec->Link) + "' in section '" +
GroupSec->Name + "' is not a symbol table");
- if (!SymTab)
- return SymTab.takeError();
-
- Expected<Symbol *> Sym = (*SymTab)->getSymbolByIndex(GroupSec->Info);
+ if (!SymTab)
+ return SymTab.takeError();
+
+ Expected<Symbol *> Sym = (*SymTab)->getSymbolByIndex(GroupSec->Info);
if (!Sym)
- return createStringError(errc::invalid_argument,
- "info field value '" + Twine(GroupSec->Info) +
- "' in section '" + GroupSec->Name +
- "' is not a valid symbol index");
- GroupSec->setSymTab(*SymTab);
- GroupSec->setSymbol(*Sym);
+ return createStringError(errc::invalid_argument,
+ "info field value '" + Twine(GroupSec->Info) +
+ "' in section '" + GroupSec->Name +
+ "' is not a valid symbol index");
+ GroupSec->setSymTab(*SymTab);
+ GroupSec->setSymbol(*Sym);
}
if (GroupSec->Contents.size() % sizeof(ELF::Elf32_Word) ||
GroupSec->Contents.empty())
- return createStringError(errc::invalid_argument,
- "the content of the section " + GroupSec->Name +
- " is malformed");
+ return createStringError(errc::invalid_argument,
+ "the content of the section " + GroupSec->Name +
+ " is malformed");
const ELF::Elf32_Word *Word =
reinterpret_cast<const ELF::Elf32_Word *>(GroupSec->Contents.data());
const ELF::Elf32_Word *End =
@@ -1508,103 +1508,103 @@ Error ELFBuilder<ELFT>::initGroupSection(GroupSection *GroupSec) {
GroupSec->setFlagWord(*Word++);
for (; Word != End; ++Word) {
uint32_t Index = support::endian::read32<ELFT::TargetEndianness>(Word);
- Expected<SectionBase *> Sec = SecTable.getSection(
+ Expected<SectionBase *> Sec = SecTable.getSection(
Index, "group member index " + Twine(Index) + " in section '" +
- GroupSec->Name + "' is invalid");
- if (!Sec)
- return Sec.takeError();
-
- GroupSec->addMember(*Sec);
+ GroupSec->Name + "' is invalid");
+ if (!Sec)
+ return Sec.takeError();
+
+ GroupSec->addMember(*Sec);
}
-
- return Error::success();
+
+ return Error::success();
}
template <class ELFT>
-Error ELFBuilder<ELFT>::initSymbolTable(SymbolTableSection *SymTab) {
- Expected<const Elf_Shdr *> Shdr = ElfFile.getSection(SymTab->Index);
- if (!Shdr)
- return Shdr.takeError();
-
- Expected<StringRef> StrTabData = ElfFile.getStringTableForSymtab(**Shdr);
- if (!StrTabData)
- return StrTabData.takeError();
-
+Error ELFBuilder<ELFT>::initSymbolTable(SymbolTableSection *SymTab) {
+ Expected<const Elf_Shdr *> Shdr = ElfFile.getSection(SymTab->Index);
+ if (!Shdr)
+ return Shdr.takeError();
+
+ Expected<StringRef> StrTabData = ElfFile.getStringTableForSymtab(**Shdr);
+ if (!StrTabData)
+ return StrTabData.takeError();
+
ArrayRef<Elf_Word> ShndxData;
- Expected<typename ELFFile<ELFT>::Elf_Sym_Range> Symbols =
- ElfFile.symbols(*Shdr);
- if (!Symbols)
- return Symbols.takeError();
-
- for (const typename ELFFile<ELFT>::Elf_Sym &Sym : *Symbols) {
+ Expected<typename ELFFile<ELFT>::Elf_Sym_Range> Symbols =
+ ElfFile.symbols(*Shdr);
+ if (!Symbols)
+ return Symbols.takeError();
+
+ for (const typename ELFFile<ELFT>::Elf_Sym &Sym : *Symbols) {
SectionBase *DefSection = nullptr;
- Expected<StringRef> Name = Sym.getName(*StrTabData);
- if (!Name)
- return Name.takeError();
-
+ Expected<StringRef> Name = Sym.getName(*StrTabData);
+ if (!Name)
+ return Name.takeError();
+
if (Sym.st_shndx == SHN_XINDEX) {
if (SymTab->getShndxTable() == nullptr)
- return createStringError(errc::invalid_argument,
- "symbol '" + *Name +
- "' has index SHN_XINDEX but no "
- "SHT_SYMTAB_SHNDX section exists");
+ return createStringError(errc::invalid_argument,
+ "symbol '" + *Name +
+ "' has index SHN_XINDEX but no "
+ "SHT_SYMTAB_SHNDX section exists");
if (ShndxData.data() == nullptr) {
- Expected<const Elf_Shdr *> ShndxSec =
- ElfFile.getSection(SymTab->getShndxTable()->Index);
- if (!ShndxSec)
- return ShndxSec.takeError();
-
- Expected<ArrayRef<Elf_Word>> Data =
- ElfFile.template getSectionContentsAsArray<Elf_Word>(**ShndxSec);
- if (!Data)
- return Data.takeError();
-
- ShndxData = *Data;
- if (ShndxData.size() != Symbols->size())
- return createStringError(
- errc::invalid_argument,
- "symbol section index table does not have the same number of "
- "entries as the symbol table");
+ Expected<const Elf_Shdr *> ShndxSec =
+ ElfFile.getSection(SymTab->getShndxTable()->Index);
+ if (!ShndxSec)
+ return ShndxSec.takeError();
+
+ Expected<ArrayRef<Elf_Word>> Data =
+ ElfFile.template getSectionContentsAsArray<Elf_Word>(**ShndxSec);
+ if (!Data)
+ return Data.takeError();
+
+ ShndxData = *Data;
+ if (ShndxData.size() != Symbols->size())
+ return createStringError(
+ errc::invalid_argument,
+ "symbol section index table does not have the same number of "
+ "entries as the symbol table");
}
- Elf_Word Index = ShndxData[&Sym - Symbols->begin()];
- Expected<SectionBase *> Sec = Obj.sections().getSection(
+ Elf_Word Index = ShndxData[&Sym - Symbols->begin()];
+ Expected<SectionBase *> Sec = Obj.sections().getSection(
Index,
- "symbol '" + *Name + "' has invalid section index " + Twine(Index));
- if (!Sec)
- return Sec.takeError();
-
- DefSection = *Sec;
+ "symbol '" + *Name + "' has invalid section index " + Twine(Index));
+ if (!Sec)
+ return Sec.takeError();
+
+ DefSection = *Sec;
} else if (Sym.st_shndx >= SHN_LORESERVE) {
if (!isValidReservedSectionIndex(Sym.st_shndx, Obj.Machine)) {
- return createStringError(
- errc::invalid_argument,
- "symbol '" + *Name +
- "' has unsupported value greater than or equal "
- "to SHN_LORESERVE: " +
- Twine(Sym.st_shndx));
+ return createStringError(
+ errc::invalid_argument,
+ "symbol '" + *Name +
+ "' has unsupported value greater than or equal "
+ "to SHN_LORESERVE: " +
+ Twine(Sym.st_shndx));
}
} else if (Sym.st_shndx != SHN_UNDEF) {
- Expected<SectionBase *> Sec = Obj.sections().getSection(
- Sym.st_shndx, "symbol '" + *Name +
+ Expected<SectionBase *> Sec = Obj.sections().getSection(
+ Sym.st_shndx, "symbol '" + *Name +
"' is defined has invalid section index " +
Twine(Sym.st_shndx));
- if (!Sec)
- return Sec.takeError();
-
- DefSection = *Sec;
+ if (!Sec)
+ return Sec.takeError();
+
+ DefSection = *Sec;
}
- SymTab->addSymbol(*Name, Sym.getBinding(), Sym.getType(), DefSection,
+ SymTab->addSymbol(*Name, Sym.getBinding(), Sym.getType(), DefSection,
Sym.getValue(), Sym.st_other, Sym.st_shndx, Sym.st_size);
}
-
- return Error::success();
+
+ return Error::success();
}
template <class ELFT>
-static void getAddend(uint64_t &, const Elf_Rel_Impl<ELFT, false> &) {}
+static void getAddend(uint64_t &, const Elf_Rel_Impl<ELFT, false> &) {}
template <class ELFT>
static void getAddend(uint64_t &ToSet, const Elf_Rel_Impl<ELFT, true> &Rela) {
@@ -1612,8 +1612,8 @@ static void getAddend(uint64_t &ToSet, const Elf_Rel_Impl<ELFT, true> &Rela) {
}
template <class T>
-static Error initRelocations(RelocationSection *Relocs,
- SymbolTableSection *SymbolTable, T RelRange) {
+static Error initRelocations(RelocationSection *Relocs,
+ SymbolTableSection *SymbolTable, T RelRange) {
for (const auto &Rel : RelRange) {
Relocation ToAdd;
ToAdd.Offset = Rel.r_offset;
@@ -1622,54 +1622,54 @@ static Error initRelocations(RelocationSection *Relocs,
if (uint32_t Sym = Rel.getSymbol(false)) {
if (!SymbolTable)
- return createStringError(
- errc::invalid_argument,
- "'" + Relocs->Name + "': relocation references symbol with index " +
- Twine(Sym) + ", but there is no symbol table");
- Expected<Symbol *> SymByIndex = SymbolTable->getSymbolByIndex(Sym);
- if (!SymByIndex)
- return SymByIndex.takeError();
-
- ToAdd.RelocSymbol = *SymByIndex;
+ return createStringError(
+ errc::invalid_argument,
+ "'" + Relocs->Name + "': relocation references symbol with index " +
+ Twine(Sym) + ", but there is no symbol table");
+ Expected<Symbol *> SymByIndex = SymbolTable->getSymbolByIndex(Sym);
+ if (!SymByIndex)
+ return SymByIndex.takeError();
+
+ ToAdd.RelocSymbol = *SymByIndex;
}
Relocs->addRelocation(ToAdd);
}
-
- return Error::success();
+
+ return Error::success();
}
-Expected<SectionBase *> SectionTableRef::getSection(uint32_t Index,
- Twine ErrMsg) {
+Expected<SectionBase *> SectionTableRef::getSection(uint32_t Index,
+ Twine ErrMsg) {
if (Index == SHN_UNDEF || Index > Sections.size())
- return createStringError(errc::invalid_argument, ErrMsg);
+ return createStringError(errc::invalid_argument, ErrMsg);
return Sections[Index - 1].get();
}
template <class T>
-Expected<T *> SectionTableRef::getSectionOfType(uint32_t Index,
- Twine IndexErrMsg,
- Twine TypeErrMsg) {
- Expected<SectionBase *> BaseSec = getSection(Index, IndexErrMsg);
- if (!BaseSec)
- return BaseSec.takeError();
-
- if (T *Sec = dyn_cast<T>(*BaseSec))
+Expected<T *> SectionTableRef::getSectionOfType(uint32_t Index,
+ Twine IndexErrMsg,
+ Twine TypeErrMsg) {
+ Expected<SectionBase *> BaseSec = getSection(Index, IndexErrMsg);
+ if (!BaseSec)
+ return BaseSec.takeError();
+
+ if (T *Sec = dyn_cast<T>(*BaseSec))
return Sec;
-
- return createStringError(errc::invalid_argument, TypeErrMsg);
+
+ return createStringError(errc::invalid_argument, TypeErrMsg);
}
template <class ELFT>
-Expected<SectionBase &> ELFBuilder<ELFT>::makeSection(const Elf_Shdr &Shdr) {
+Expected<SectionBase &> ELFBuilder<ELFT>::makeSection(const Elf_Shdr &Shdr) {
switch (Shdr.sh_type) {
case SHT_REL:
case SHT_RELA:
if (Shdr.sh_flags & SHF_ALLOC) {
- if (Expected<ArrayRef<uint8_t>> Data = ElfFile.getSectionContents(Shdr))
- return Obj.addSection<DynamicRelocationSection>(*Data);
- else
- return Data.takeError();
+ if (Expected<ArrayRef<uint8_t>> Data = ElfFile.getSectionContents(Shdr))
+ return Obj.addSection<DynamicRelocationSection>(*Data);
+ else
+ return Data.takeError();
}
return Obj.addSection<RelocationSection>();
case SHT_STRTAB:
@@ -1677,35 +1677,35 @@ Expected<SectionBase &> ELFBuilder<ELFT>::makeSection(const Elf_Shdr &Shdr) {
// mean altering the memory image. There are no special link types or
// anything so we can just use a Section.
if (Shdr.sh_flags & SHF_ALLOC) {
- if (Expected<ArrayRef<uint8_t>> Data = ElfFile.getSectionContents(Shdr))
- return Obj.addSection<Section>(*Data);
- else
- return Data.takeError();
+ if (Expected<ArrayRef<uint8_t>> Data = ElfFile.getSectionContents(Shdr))
+ return Obj.addSection<Section>(*Data);
+ else
+ return Data.takeError();
}
return Obj.addSection<StringTableSection>();
case SHT_HASH:
case SHT_GNU_HASH:
// Hash tables should refer to SHT_DYNSYM which we're not going to change.
// Because of this we don't need to mess with the hash tables either.
- if (Expected<ArrayRef<uint8_t>> Data = ElfFile.getSectionContents(Shdr))
- return Obj.addSection<Section>(*Data);
- else
- return Data.takeError();
+ if (Expected<ArrayRef<uint8_t>> Data = ElfFile.getSectionContents(Shdr))
+ return Obj.addSection<Section>(*Data);
+ else
+ return Data.takeError();
case SHT_GROUP:
- if (Expected<ArrayRef<uint8_t>> Data = ElfFile.getSectionContents(Shdr))
- return Obj.addSection<GroupSection>(*Data);
- else
- return Data.takeError();
+ if (Expected<ArrayRef<uint8_t>> Data = ElfFile.getSectionContents(Shdr))
+ return Obj.addSection<GroupSection>(*Data);
+ else
+ return Data.takeError();
case SHT_DYNSYM:
- if (Expected<ArrayRef<uint8_t>> Data = ElfFile.getSectionContents(Shdr))
- return Obj.addSection<DynamicSymbolTableSection>(*Data);
- else
- return Data.takeError();
+ if (Expected<ArrayRef<uint8_t>> Data = ElfFile.getSectionContents(Shdr))
+ return Obj.addSection<DynamicSymbolTableSection>(*Data);
+ else
+ return Data.takeError();
case SHT_DYNAMIC:
- if (Expected<ArrayRef<uint8_t>> Data = ElfFile.getSectionContents(Shdr))
- return Obj.addSection<DynamicSection>(*Data);
- else
- return Data.takeError();
+ if (Expected<ArrayRef<uint8_t>> Data = ElfFile.getSectionContents(Shdr))
+ return Obj.addSection<DynamicSection>(*Data);
+ else
+ return Data.takeError();
case SHT_SYMTAB: {
auto &SymTab = Obj.addSection<SymbolTableSection>();
Obj.SymbolTable = &SymTab;
@@ -1717,176 +1717,176 @@ Expected<SectionBase &> ELFBuilder<ELFT>::makeSection(const Elf_Shdr &Shdr) {
return ShndxSection;
}
case SHT_NOBITS:
- return Obj.addSection<Section>(ArrayRef<uint8_t>());
+ return Obj.addSection<Section>(ArrayRef<uint8_t>());
default: {
- Expected<ArrayRef<uint8_t>> Data = ElfFile.getSectionContents(Shdr);
- if (!Data)
- return Data.takeError();
-
- Expected<StringRef> Name = ElfFile.getSectionName(Shdr);
- if (!Name)
- return Name.takeError();
-
- if (Name->startswith(".zdebug") || (Shdr.sh_flags & ELF::SHF_COMPRESSED)) {
+ Expected<ArrayRef<uint8_t>> Data = ElfFile.getSectionContents(Shdr);
+ if (!Data)
+ return Data.takeError();
+
+ Expected<StringRef> Name = ElfFile.getSectionName(Shdr);
+ if (!Name)
+ return Name.takeError();
+
+ if (Name->startswith(".zdebug") || (Shdr.sh_flags & ELF::SHF_COMPRESSED)) {
uint64_t DecompressedSize, DecompressedAlign;
std::tie(DecompressedSize, DecompressedAlign) =
- getDecompressedSizeAndAlignment<ELFT>(*Data);
- Expected<CompressedSection> NewSection =
- CompressedSection::create(*Data, DecompressedSize, DecompressedAlign);
- if (!NewSection)
- return NewSection.takeError();
-
- return Obj.addSection<CompressedSection>(std::move(*NewSection));
+ getDecompressedSizeAndAlignment<ELFT>(*Data);
+ Expected<CompressedSection> NewSection =
+ CompressedSection::create(*Data, DecompressedSize, DecompressedAlign);
+ if (!NewSection)
+ return NewSection.takeError();
+
+ return Obj.addSection<CompressedSection>(std::move(*NewSection));
}
- return Obj.addSection<Section>(*Data);
+ return Obj.addSection<Section>(*Data);
}
}
}
-template <class ELFT> Error ELFBuilder<ELFT>::readSectionHeaders() {
+template <class ELFT> Error ELFBuilder<ELFT>::readSectionHeaders() {
uint32_t Index = 0;
- Expected<typename ELFFile<ELFT>::Elf_Shdr_Range> Sections =
- ElfFile.sections();
- if (!Sections)
- return Sections.takeError();
-
- for (const typename ELFFile<ELFT>::Elf_Shdr &Shdr : *Sections) {
+ Expected<typename ELFFile<ELFT>::Elf_Shdr_Range> Sections =
+ ElfFile.sections();
+ if (!Sections)
+ return Sections.takeError();
+
+ for (const typename ELFFile<ELFT>::Elf_Shdr &Shdr : *Sections) {
if (Index == 0) {
++Index;
continue;
}
- Expected<SectionBase &> Sec = makeSection(Shdr);
- if (!Sec)
- return Sec.takeError();
-
- Expected<StringRef> SecName = ElfFile.getSectionName(Shdr);
- if (!SecName)
- return SecName.takeError();
- Sec->Name = SecName->str();
- Sec->Type = Sec->OriginalType = Shdr.sh_type;
- Sec->Flags = Sec->OriginalFlags = Shdr.sh_flags;
- Sec->Addr = Shdr.sh_addr;
- Sec->Offset = Shdr.sh_offset;
- Sec->OriginalOffset = Shdr.sh_offset;
- Sec->Size = Shdr.sh_size;
- Sec->Link = Shdr.sh_link;
- Sec->Info = Shdr.sh_info;
- Sec->Align = Shdr.sh_addralign;
- Sec->EntrySize = Shdr.sh_entsize;
- Sec->Index = Index++;
- Sec->OriginalIndex = Sec->Index;
- Sec->OriginalData =
+ Expected<SectionBase &> Sec = makeSection(Shdr);
+ if (!Sec)
+ return Sec.takeError();
+
+ Expected<StringRef> SecName = ElfFile.getSectionName(Shdr);
+ if (!SecName)
+ return SecName.takeError();
+ Sec->Name = SecName->str();
+ Sec->Type = Sec->OriginalType = Shdr.sh_type;
+ Sec->Flags = Sec->OriginalFlags = Shdr.sh_flags;
+ Sec->Addr = Shdr.sh_addr;
+ Sec->Offset = Shdr.sh_offset;
+ Sec->OriginalOffset = Shdr.sh_offset;
+ Sec->Size = Shdr.sh_size;
+ Sec->Link = Shdr.sh_link;
+ Sec->Info = Shdr.sh_info;
+ Sec->Align = Shdr.sh_addralign;
+ Sec->EntrySize = Shdr.sh_entsize;
+ Sec->Index = Index++;
+ Sec->OriginalIndex = Sec->Index;
+ Sec->OriginalData =
ArrayRef<uint8_t>(ElfFile.base() + Shdr.sh_offset,
(Shdr.sh_type == SHT_NOBITS) ? 0 : Shdr.sh_size);
}
-
- return Error::success();
+
+ return Error::success();
}
-template <class ELFT> Error ELFBuilder<ELFT>::readSections(bool EnsureSymtab) {
- uint32_t ShstrIndex = ElfFile.getHeader().e_shstrndx;
- if (ShstrIndex == SHN_XINDEX) {
- Expected<const Elf_Shdr *> Sec = ElfFile.getSection(0);
- if (!Sec)
- return Sec.takeError();
-
- ShstrIndex = (*Sec)->sh_link;
- }
+template <class ELFT> Error ELFBuilder<ELFT>::readSections(bool EnsureSymtab) {
+ uint32_t ShstrIndex = ElfFile.getHeader().e_shstrndx;
+ if (ShstrIndex == SHN_XINDEX) {
+ Expected<const Elf_Shdr *> Sec = ElfFile.getSection(0);
+ if (!Sec)
+ return Sec.takeError();
+ ShstrIndex = (*Sec)->sh_link;
+ }
+
if (ShstrIndex == SHN_UNDEF)
Obj.HadShdrs = false;
- else {
- Expected<StringTableSection *> Sec =
+ else {
+ Expected<StringTableSection *> Sec =
Obj.sections().template getSectionOfType<StringTableSection>(
ShstrIndex,
"e_shstrndx field value " + Twine(ShstrIndex) + " in elf header " +
" is invalid",
"e_shstrndx field value " + Twine(ShstrIndex) + " in elf header " +
" does not reference a string table");
- if (!Sec)
- return Sec.takeError();
-
- Obj.SectionNames = *Sec;
- }
+ if (!Sec)
+ return Sec.takeError();
+ Obj.SectionNames = *Sec;
+ }
+
// If a section index table exists we'll need to initialize it before we
// initialize the symbol table because the symbol table might need to
// reference it.
if (Obj.SectionIndexTable)
- if (Error Err = Obj.SectionIndexTable->initialize(Obj.sections()))
- return Err;
+ if (Error Err = Obj.SectionIndexTable->initialize(Obj.sections()))
+ return Err;
// Now that all of the sections have been added we can fill out some extra
// details about symbol tables. We need the symbol table filled out before
// any relocations.
if (Obj.SymbolTable) {
- if (Error Err = Obj.SymbolTable->initialize(Obj.sections()))
- return Err;
- if (Error Err = initSymbolTable(Obj.SymbolTable))
- return Err;
+ if (Error Err = Obj.SymbolTable->initialize(Obj.sections()))
+ return Err;
+ if (Error Err = initSymbolTable(Obj.SymbolTable))
+ return Err;
} else if (EnsureSymtab) {
- if (Error Err = Obj.addNewSymbolTable())
- return Err;
+ if (Error Err = Obj.addNewSymbolTable())
+ return Err;
}
// Now that all sections and symbols have been added we can add
// relocations that reference symbols and set the link and info fields for
// relocation sections.
- for (SectionBase &Sec : Obj.sections()) {
+ for (SectionBase &Sec : Obj.sections()) {
if (&Sec == Obj.SymbolTable)
continue;
- if (Error Err = Sec.initialize(Obj.sections()))
- return Err;
+ if (Error Err = Sec.initialize(Obj.sections()))
+ return Err;
if (auto RelSec = dyn_cast<RelocationSection>(&Sec)) {
- Expected<typename ELFFile<ELFT>::Elf_Shdr_Range> Sections =
- ElfFile.sections();
- if (!Sections)
- return Sections.takeError();
-
- const typename ELFFile<ELFT>::Elf_Shdr *Shdr =
- Sections->begin() + RelSec->Index;
- if (RelSec->Type == SHT_REL) {
- Expected<typename ELFFile<ELFT>::Elf_Rel_Range> Rels =
- ElfFile.rels(*Shdr);
- if (!Rels)
- return Rels.takeError();
-
- if (Error Err = initRelocations(RelSec, Obj.SymbolTable, *Rels))
- return Err;
- } else {
- Expected<typename ELFFile<ELFT>::Elf_Rela_Range> Relas =
- ElfFile.relas(*Shdr);
- if (!Relas)
- return Relas.takeError();
-
- if (Error Err = initRelocations(RelSec, Obj.SymbolTable, *Relas))
- return Err;
- }
+ Expected<typename ELFFile<ELFT>::Elf_Shdr_Range> Sections =
+ ElfFile.sections();
+ if (!Sections)
+ return Sections.takeError();
+
+ const typename ELFFile<ELFT>::Elf_Shdr *Shdr =
+ Sections->begin() + RelSec->Index;
+ if (RelSec->Type == SHT_REL) {
+ Expected<typename ELFFile<ELFT>::Elf_Rel_Range> Rels =
+ ElfFile.rels(*Shdr);
+ if (!Rels)
+ return Rels.takeError();
+
+ if (Error Err = initRelocations(RelSec, Obj.SymbolTable, *Rels))
+ return Err;
+ } else {
+ Expected<typename ELFFile<ELFT>::Elf_Rela_Range> Relas =
+ ElfFile.relas(*Shdr);
+ if (!Relas)
+ return Relas.takeError();
+
+ if (Error Err = initRelocations(RelSec, Obj.SymbolTable, *Relas))
+ return Err;
+ }
} else if (auto GroupSec = dyn_cast<GroupSection>(&Sec)) {
- if (Error Err = initGroupSection(GroupSec))
- return Err;
+ if (Error Err = initGroupSection(GroupSec))
+ return Err;
}
}
-
- return Error::success();
+
+ return Error::success();
}
-template <class ELFT> Error ELFBuilder<ELFT>::build(bool EnsureSymtab) {
- if (Error E = readSectionHeaders())
- return E;
- if (Error E = findEhdrOffset())
- return E;
+template <class ELFT> Error ELFBuilder<ELFT>::build(bool EnsureSymtab) {
+ if (Error E = readSectionHeaders())
+ return E;
+ if (Error E = findEhdrOffset())
+ return E;
// The ELFFile whose ELF headers and program headers are copied into the
// output file. Normally the same as ElfFile, but if we're extracting a
// loadable partition it will point to the partition's headers.
- Expected<ELFFile<ELFT>> HeadersFile = ELFFile<ELFT>::create(toStringRef(
- {ElfFile.base() + EhdrOffset, ElfFile.getBufSize() - EhdrOffset}));
- if (!HeadersFile)
- return HeadersFile.takeError();
+ Expected<ELFFile<ELFT>> HeadersFile = ELFFile<ELFT>::create(toStringRef(
+ {ElfFile.base() + EhdrOffset, ElfFile.getBufSize() - EhdrOffset}));
+ if (!HeadersFile)
+ return HeadersFile.takeError();
- const typename ELFFile<ELFT>::Elf_Ehdr &Ehdr = HeadersFile->getHeader();
+ const typename ELFFile<ELFT>::Elf_Ehdr &Ehdr = HeadersFile->getHeader();
Obj.OSABI = Ehdr.e_ident[EI_OSABI];
Obj.ABIVersion = Ehdr.e_ident[EI_ABIVERSION];
Obj.Type = Ehdr.e_type;
@@ -1895,17 +1895,17 @@ template <class ELFT> Error ELFBuilder<ELFT>::build(bool EnsureSymtab) {
Obj.Entry = Ehdr.e_entry;
Obj.Flags = Ehdr.e_flags;
- if (Error E = readSections(EnsureSymtab))
- return E;
- return readProgramHeaders(*HeadersFile);
+ if (Error E = readSections(EnsureSymtab))
+ return E;
+ return readProgramHeaders(*HeadersFile);
}
Writer::~Writer() {}
Reader::~Reader() {}
-Expected<std::unique_ptr<Object>>
-BinaryReader::create(bool /*EnsureSymtab*/) const {
+Expected<std::unique_ptr<Object>>
+BinaryReader::create(bool /*EnsureSymtab*/) const {
return BinaryELFBuilder(MemBuf, NewSymbolVisibility).build();
}
@@ -1935,39 +1935,39 @@ Expected<std::vector<IHexRecord>> IHexReader::parse() const {
return std::move(Records);
}
-Expected<std::unique_ptr<Object>>
-IHexReader::create(bool /*EnsureSymtab*/) const {
- Expected<std::vector<IHexRecord>> Records = parse();
- if (!Records)
- return Records.takeError();
-
- return IHexELFBuilder(*Records).build();
+Expected<std::unique_ptr<Object>>
+IHexReader::create(bool /*EnsureSymtab*/) const {
+ Expected<std::vector<IHexRecord>> Records = parse();
+ if (!Records)
+ return Records.takeError();
+
+ return IHexELFBuilder(*Records).build();
}
-Expected<std::unique_ptr<Object>> ELFReader::create(bool EnsureSymtab) const {
+Expected<std::unique_ptr<Object>> ELFReader::create(bool EnsureSymtab) const {
auto Obj = std::make_unique<Object>();
if (auto *O = dyn_cast<ELFObjectFile<ELF32LE>>(Bin)) {
ELFBuilder<ELF32LE> Builder(*O, *Obj, ExtractPartition);
- if (Error Err = Builder.build(EnsureSymtab))
- return std::move(Err);
- return std::move(Obj);
+ if (Error Err = Builder.build(EnsureSymtab))
+ return std::move(Err);
+ return std::move(Obj);
} else if (auto *O = dyn_cast<ELFObjectFile<ELF64LE>>(Bin)) {
ELFBuilder<ELF64LE> Builder(*O, *Obj, ExtractPartition);
- if (Error Err = Builder.build(EnsureSymtab))
- return std::move(Err);
- return std::move(Obj);
+ if (Error Err = Builder.build(EnsureSymtab))
+ return std::move(Err);
+ return std::move(Obj);
} else if (auto *O = dyn_cast<ELFObjectFile<ELF32BE>>(Bin)) {
ELFBuilder<ELF32BE> Builder(*O, *Obj, ExtractPartition);
- if (Error Err = Builder.build(EnsureSymtab))
- return std::move(Err);
- return std::move(Obj);
+ if (Error Err = Builder.build(EnsureSymtab))
+ return std::move(Err);
+ return std::move(Obj);
} else if (auto *O = dyn_cast<ELFObjectFile<ELF64BE>>(Bin)) {
ELFBuilder<ELF64BE> Builder(*O, *Obj, ExtractPartition);
- if (Error Err = Builder.build(EnsureSymtab))
- return std::move(Err);
- return std::move(Obj);
+ if (Error Err = Builder.build(EnsureSymtab))
+ return std::move(Err);
+ return std::move(Obj);
}
- return createStringError(errc::invalid_argument, "invalid file type");
+ return createStringError(errc::invalid_argument, "invalid file type");
}
template <class ELFT> void ELFWriter<ELFT>::writeEhdr() {
@@ -2061,16 +2061,16 @@ template <class ELFT> void ELFWriter<ELFT>::writeShdrs() {
writeShdr(Sec);
}
-template <class ELFT> Error ELFWriter<ELFT>::writeSectionData() {
+template <class ELFT> Error ELFWriter<ELFT>::writeSectionData() {
for (SectionBase &Sec : Obj.sections())
// Segments are responsible for writing their contents, so only write the
// section data if the section is not in a segment. Note that this renders
// sections in segments effectively immutable.
if (Sec.ParentSegment == nullptr)
- if (Error Err = Sec.accept(*SecWriter))
- return Err;
-
- return Error::success();
+ if (Error Err = Sec.accept(*SecWriter))
+ return Err;
+
+ return Error::success();
}
template <class ELFT> void ELFWriter<ELFT>::writeSegmentData() {
@@ -2097,8 +2097,8 @@ ELFWriter<ELFT>::ELFWriter(Object &Obj, Buffer &Buf, bool WSH,
: Writer(Obj, Buf), WriteSectionHeaders(WSH && Obj.HadShdrs),
OnlyKeepDebug(OnlyKeepDebug) {}
-Error Object::removeSections(
- bool AllowBrokenLinks, std::function<bool(const SectionBase &)> ToRemove) {
+Error Object::removeSections(
+ bool AllowBrokenLinks, std::function<bool(const SectionBase &)> ToRemove) {
auto Iter = std::stable_partition(
std::begin(Sections), std::end(Sections), [=](const SecPtr &Sec) {
@@ -2134,8 +2134,8 @@ Error Object::removeSections(
// a live section critically depends on a section being removed somehow
// (e.g. the removed section is referenced by a relocation).
for (auto &KeepSec : make_range(std::begin(Sections), Iter)) {
- if (Error E = KeepSec->removeSectionReferences(
- AllowBrokenLinks, [&RemoveSections](const SectionBase *Sec) {
+ if (Error E = KeepSec->removeSectionReferences(
+ AllowBrokenLinks, [&RemoveSections](const SectionBase *Sec) {
return RemoveSections.find(Sec) != RemoveSections.end();
}))
return E;
@@ -2157,7 +2157,7 @@ Error Object::removeSymbols(function_ref<bool(const Symbol &)> ToRemove) {
return Error::success();
}
-Error Object::addNewSymbolTable() {
+Error Object::addNewSymbolTable() {
assert(!SymbolTable && "Object must not has a SymbolTable.");
// Reuse an existing SHT_STRTAB section if it exists.
@@ -2178,13 +2178,13 @@ Error Object::addNewSymbolTable() {
SymbolTableSection &SymTab = addSection<SymbolTableSection>();
SymTab.Name = ".symtab";
SymTab.Link = StrTab->Index;
- if (Error Err = SymTab.initialize(sections()))
- return Err;
+ if (Error Err = SymTab.initialize(sections()))
+ return Err;
SymTab.addSymbol("", 0, 0, nullptr, 0, 0, 0, 0);
SymbolTable = &SymTab;
-
- return Error::success();
+
+ return Error::success();
}
void Object::sortSections() {
@@ -2305,19 +2305,19 @@ static uint64_t layoutSectionsForOnlyKeepDebug(Object &Obj, uint64_t Off) {
return Off;
}
-// Rewrite p_offset and p_filesz of non-PT_PHDR segments after sh_offset values
-// have been updated.
+// Rewrite p_offset and p_filesz of non-PT_PHDR segments after sh_offset values
+// have been updated.
static uint64_t layoutSegmentsForOnlyKeepDebug(std::vector<Segment *> &Segments,
uint64_t HdrEnd) {
uint64_t MaxOffset = 0;
for (Segment *Seg : Segments) {
- // An empty segment contains no section (see sectionWithinSegment). If it
- // has a parent segment, copy the parent segment's offset field. This works
- // for empty PT_TLS. We don't handle empty segments without a parent for
- // now.
- if (Seg->ParentSegment != nullptr && Seg->MemSize == 0)
- Seg->Offset = Seg->ParentSegment->Offset;
-
+ // An empty segment contains no section (see sectionWithinSegment). If it
+ // has a parent segment, copy the parent segment's offset field. This works
+ // for empty PT_TLS. We don't handle empty segments without a parent for
+ // now.
+ if (Seg->ParentSegment != nullptr && Seg->MemSize == 0)
+ Seg->Offset = Seg->ParentSegment->Offset;
+
const SectionBase *FirstSec = Seg->firstSection();
if (Seg->Type == PT_PHDR || !FirstSec)
continue;
@@ -2405,8 +2405,8 @@ template <class ELFT> Error ELFWriter<ELFT>::write() {
writeSegmentData();
writeEhdr();
writePhdrs();
- if (Error E = writeSectionData())
- return E;
+ if (Error E = writeSectionData())
+ return E;
if (WriteSectionHeaders)
writeShdrs();
return Buf.commit();
@@ -2451,8 +2451,8 @@ template <class ELFT> Error ELFWriter<ELFT>::finalize() {
if (Obj.sections().size() >= SHN_LORESERVE) {
SectionTableRef Sections = Obj.sections();
NeedsLargeIndexes =
- any_of(drop_begin(Sections, SHN_LORESERVE),
- [](const SectionBase &Sec) { return Sec.HasSymbol; });
+ any_of(drop_begin(Sections, SHN_LORESERVE),
+ [](const SectionBase &Sec) { return Sec.HasSymbol; });
// TODO: handle case where only one section needs the large index table but
// only needs it because the large index table hasn't been removed yet.
}
@@ -2495,8 +2495,8 @@ template <class ELFT> Error ELFWriter<ELFT>::finalize() {
auto SecSizer = std::make_unique<ELFSectionSizer<ELFT>>();
for (SectionBase &Sec : Obj.sections()) {
Sec.Index = Index++;
- if (Error Err = Sec.accept(*SecSizer))
- return Err;
+ if (Error Err = Sec.accept(*SecSizer))
+ return Err;
}
// The symbol table does not update all other sections on update. For
@@ -2537,9 +2537,9 @@ template <class ELFT> Error ELFWriter<ELFT>::finalize() {
Error BinaryWriter::write() {
for (const SectionBase &Sec : Obj.allocSections())
- if (Error Err = Sec.accept(*SecWriter))
- return Err;
-
+ if (Error Err = Sec.accept(*SecWriter))
+ return Err;
+
return Buf.commit();
}
@@ -2611,8 +2611,8 @@ Error IHexWriter::write() {
IHexSectionWriter Writer(Buf);
// Write sections.
for (const SectionBase *Sec : Sections)
- if (Error Err = Sec->accept(Writer))
- return Err;
+ if (Error Err = Sec->accept(Writer))
+ return Err;
uint64_t Offset = Writer.getBufferOffset();
// Write entry point address.
@@ -2628,8 +2628,8 @@ Error IHexWriter::checkSection(const SectionBase &Sec) {
if (addressOverflows32bit(Addr) || addressOverflows32bit(Addr + Sec.Size - 1))
return createStringError(
errc::invalid_argument,
- "Section '%s' address range [0x%llx, 0x%llx] is not 32 bit",
- Sec.Name.c_str(), Addr, Addr + Sec.Size - 1);
+ "Section '%s' address range [0x%llx, 0x%llx] is not 32 bit",
+ Sec.Name.c_str(), Addr, Addr + Sec.Size - 1);
return Error::success();
}
@@ -2666,8 +2666,8 @@ Error IHexWriter::finalize() {
IHexSectionWriterBase LengthCalc(Buf);
for (const SectionBase *Sec : Sections)
- if (Error Err = Sec->accept(LengthCalc))
- return Err;
+ if (Error Err = Sec->accept(LengthCalc))
+ return Err;
// We need space to write section records + StartAddress record
// (if start adress is not zero) + EndOfFile record.
diff --git a/contrib/libs/llvm12/tools/llvm-objcopy/ELF/Object.h b/contrib/libs/llvm12/tools/llvm-objcopy/ELF/Object.h
index 0205c2d4f3..01caa5d42a 100644
--- a/contrib/libs/llvm12/tools/llvm-objcopy/ELF/Object.h
+++ b/contrib/libs/llvm12/tools/llvm-objcopy/ELF/Object.h
@@ -61,11 +61,11 @@ public:
iterator end() const { return iterator(Sections.data() + Sections.size()); }
size_t size() const { return Sections.size(); }
- Expected<SectionBase *> getSection(uint32_t Index, Twine ErrMsg);
+ Expected<SectionBase *> getSection(uint32_t Index, Twine ErrMsg);
template <class T>
- Expected<T *> getSectionOfType(uint32_t Index, Twine IndexErrMsg,
- Twine TypeErrMsg);
+ Expected<T *> getSectionOfType(uint32_t Index, Twine IndexErrMsg,
+ Twine TypeErrMsg);
};
enum ElfType { ELFT_ELF32LE, ELFT_ELF64LE, ELFT_ELF32BE, ELFT_ELF64BE };
@@ -74,34 +74,34 @@ class SectionVisitor {
public:
virtual ~SectionVisitor() = default;
- virtual Error visit(const Section &Sec) = 0;
- virtual Error visit(const OwnedDataSection &Sec) = 0;
- virtual Error visit(const StringTableSection &Sec) = 0;
- virtual Error visit(const SymbolTableSection &Sec) = 0;
- virtual Error visit(const RelocationSection &Sec) = 0;
- virtual Error visit(const DynamicRelocationSection &Sec) = 0;
- virtual Error visit(const GnuDebugLinkSection &Sec) = 0;
- virtual Error visit(const GroupSection &Sec) = 0;
- virtual Error visit(const SectionIndexSection &Sec) = 0;
- virtual Error visit(const CompressedSection &Sec) = 0;
- virtual Error visit(const DecompressedSection &Sec) = 0;
+ virtual Error visit(const Section &Sec) = 0;
+ virtual Error visit(const OwnedDataSection &Sec) = 0;
+ virtual Error visit(const StringTableSection &Sec) = 0;
+ virtual Error visit(const SymbolTableSection &Sec) = 0;
+ virtual Error visit(const RelocationSection &Sec) = 0;
+ virtual Error visit(const DynamicRelocationSection &Sec) = 0;
+ virtual Error visit(const GnuDebugLinkSection &Sec) = 0;
+ virtual Error visit(const GroupSection &Sec) = 0;
+ virtual Error visit(const SectionIndexSection &Sec) = 0;
+ virtual Error visit(const CompressedSection &Sec) = 0;
+ virtual Error visit(const DecompressedSection &Sec) = 0;
};
class MutableSectionVisitor {
public:
virtual ~MutableSectionVisitor() = default;
- virtual Error visit(Section &Sec) = 0;
- virtual Error visit(OwnedDataSection &Sec) = 0;
- virtual Error visit(StringTableSection &Sec) = 0;
- virtual Error visit(SymbolTableSection &Sec) = 0;
- virtual Error visit(RelocationSection &Sec) = 0;
- virtual Error visit(DynamicRelocationSection &Sec) = 0;
- virtual Error visit(GnuDebugLinkSection &Sec) = 0;
- virtual Error visit(GroupSection &Sec) = 0;
- virtual Error visit(SectionIndexSection &Sec) = 0;
- virtual Error visit(CompressedSection &Sec) = 0;
- virtual Error visit(DecompressedSection &Sec) = 0;
+ virtual Error visit(Section &Sec) = 0;
+ virtual Error visit(OwnedDataSection &Sec) = 0;
+ virtual Error visit(StringTableSection &Sec) = 0;
+ virtual Error visit(SymbolTableSection &Sec) = 0;
+ virtual Error visit(RelocationSection &Sec) = 0;
+ virtual Error visit(DynamicRelocationSection &Sec) = 0;
+ virtual Error visit(GnuDebugLinkSection &Sec) = 0;
+ virtual Error visit(GroupSection &Sec) = 0;
+ virtual Error visit(SectionIndexSection &Sec) = 0;
+ virtual Error visit(CompressedSection &Sec) = 0;
+ virtual Error visit(DecompressedSection &Sec) = 0;
};
class SectionWriter : public SectionVisitor {
@@ -111,17 +111,17 @@ protected:
public:
virtual ~SectionWriter() = default;
- Error visit(const Section &Sec) override;
- Error visit(const OwnedDataSection &Sec) override;
- Error visit(const StringTableSection &Sec) override;
- Error visit(const DynamicRelocationSection &Sec) override;
- virtual Error visit(const SymbolTableSection &Sec) override = 0;
- virtual Error visit(const RelocationSection &Sec) override = 0;
- virtual Error visit(const GnuDebugLinkSection &Sec) override = 0;
- virtual Error visit(const GroupSection &Sec) override = 0;
- virtual Error visit(const SectionIndexSection &Sec) override = 0;
- virtual Error visit(const CompressedSection &Sec) override = 0;
- virtual Error visit(const DecompressedSection &Sec) override = 0;
+ Error visit(const Section &Sec) override;
+ Error visit(const OwnedDataSection &Sec) override;
+ Error visit(const StringTableSection &Sec) override;
+ Error visit(const DynamicRelocationSection &Sec) override;
+ virtual Error visit(const SymbolTableSection &Sec) override = 0;
+ virtual Error visit(const RelocationSection &Sec) override = 0;
+ virtual Error visit(const GnuDebugLinkSection &Sec) override = 0;
+ virtual Error visit(const GroupSection &Sec) override = 0;
+ virtual Error visit(const SectionIndexSection &Sec) override = 0;
+ virtual Error visit(const CompressedSection &Sec) override = 0;
+ virtual Error visit(const DecompressedSection &Sec) override = 0;
explicit SectionWriter(Buffer &Buf) : Out(Buf) {}
};
@@ -135,13 +135,13 @@ private:
public:
virtual ~ELFSectionWriter() {}
- Error visit(const SymbolTableSection &Sec) override;
- Error visit(const RelocationSection &Sec) override;
- Error visit(const GnuDebugLinkSection &Sec) override;
- Error visit(const GroupSection &Sec) override;
- Error visit(const SectionIndexSection &Sec) override;
- Error visit(const CompressedSection &Sec) override;
- Error visit(const DecompressedSection &Sec) override;
+ Error visit(const SymbolTableSection &Sec) override;
+ Error visit(const RelocationSection &Sec) override;
+ Error visit(const GnuDebugLinkSection &Sec) override;
+ Error visit(const GroupSection &Sec) override;
+ Error visit(const SectionIndexSection &Sec) override;
+ Error visit(const CompressedSection &Sec) override;
+ Error visit(const DecompressedSection &Sec) override;
explicit ELFSectionWriter(Buffer &Buf) : SectionWriter(Buf) {}
};
@@ -155,17 +155,17 @@ private:
using Elf_Xword = typename ELFT::Xword;
public:
- Error visit(Section &Sec) override;
- Error visit(OwnedDataSection &Sec) override;
- Error visit(StringTableSection &Sec) override;
- Error visit(DynamicRelocationSection &Sec) override;
- Error visit(SymbolTableSection &Sec) override;
- Error visit(RelocationSection &Sec) override;
- Error visit(GnuDebugLinkSection &Sec) override;
- Error visit(GroupSection &Sec) override;
- Error visit(SectionIndexSection &Sec) override;
- Error visit(CompressedSection &Sec) override;
- Error visit(DecompressedSection &Sec) override;
+ Error visit(Section &Sec) override;
+ Error visit(OwnedDataSection &Sec) override;
+ Error visit(StringTableSection &Sec) override;
+ Error visit(DynamicRelocationSection &Sec) override;
+ Error visit(SymbolTableSection &Sec) override;
+ Error visit(RelocationSection &Sec) override;
+ Error visit(GnuDebugLinkSection &Sec) override;
+ Error visit(GroupSection &Sec) override;
+ Error visit(SectionIndexSection &Sec) override;
+ Error visit(CompressedSection &Sec) override;
+ Error visit(DecompressedSection &Sec) override;
};
#define MAKE_SEC_WRITER_FRIEND \
@@ -179,13 +179,13 @@ class BinarySectionWriter : public SectionWriter {
public:
virtual ~BinarySectionWriter() {}
- Error visit(const SymbolTableSection &Sec) override;
- Error visit(const RelocationSection &Sec) override;
- Error visit(const GnuDebugLinkSection &Sec) override;
- Error visit(const GroupSection &Sec) override;
- Error visit(const SectionIndexSection &Sec) override;
- Error visit(const CompressedSection &Sec) override;
- Error visit(const DecompressedSection &Sec) override;
+ Error visit(const SymbolTableSection &Sec) override;
+ Error visit(const RelocationSection &Sec) override;
+ Error visit(const GnuDebugLinkSection &Sec) override;
+ Error visit(const GroupSection &Sec) override;
+ Error visit(const SectionIndexSection &Sec) override;
+ Error visit(const CompressedSection &Sec) override;
+ Error visit(const DecompressedSection &Sec) override;
explicit BinarySectionWriter(Buffer &Buf) : SectionWriter(Buf) {}
};
@@ -286,10 +286,10 @@ public:
explicit IHexSectionWriterBase(Buffer &Buf) : BinarySectionWriter(Buf) {}
uint64_t getBufferOffset() const { return Offset; }
- Error visit(const Section &Sec) final;
- Error visit(const OwnedDataSection &Sec) final;
- Error visit(const StringTableSection &Sec) override;
- Error visit(const DynamicRelocationSection &Sec) final;
+ Error visit(const Section &Sec) final;
+ Error visit(const OwnedDataSection &Sec) final;
+ Error visit(const StringTableSection &Sec) override;
+ Error visit(const DynamicRelocationSection &Sec) final;
using BinarySectionWriter::visit;
};
@@ -299,7 +299,7 @@ public:
IHexSectionWriter(Buffer &Buf) : IHexSectionWriterBase(Buf) {}
void writeData(uint8_t Type, uint16_t Addr, ArrayRef<uint8_t> Data) override;
- Error visit(const StringTableSection &Sec) override;
+ Error visit(const StringTableSection &Sec) override;
};
class Writer {
@@ -330,7 +330,7 @@ private:
void writePhdrs();
void writeShdrs();
- Error writeSectionData();
+ Error writeSectionData();
void writeSegmentData();
void assignOffsets();
@@ -391,7 +391,7 @@ public:
uint64_t HeaderOffset = 0;
uint32_t Index = 0;
- uint32_t OriginalIndex = 0;
+ uint32_t OriginalIndex = 0;
uint64_t OriginalFlags = 0;
uint64_t OriginalType = ELF::SHT_NULL;
uint64_t OriginalOffset = std::numeric_limits<uint64_t>::max();
@@ -407,22 +407,22 @@ public:
uint64_t Size = 0;
uint64_t Type = ELF::SHT_NULL;
ArrayRef<uint8_t> OriginalData;
- bool HasSymbol = false;
+ bool HasSymbol = false;
SectionBase() = default;
SectionBase(const SectionBase &) = default;
virtual ~SectionBase() = default;
- virtual Error initialize(SectionTableRef SecTable);
+ virtual Error initialize(SectionTableRef SecTable);
virtual void finalize();
// Remove references to these sections. The list of sections must be sorted.
virtual Error
removeSectionReferences(bool AllowBrokenLinks,
function_ref<bool(const SectionBase *)> ToRemove);
virtual Error removeSymbols(function_ref<bool(const Symbol &)> ToRemove);
- virtual Error accept(SectionVisitor &Visitor) const = 0;
- virtual Error accept(MutableSectionVisitor &Visitor) = 0;
+ virtual Error accept(SectionVisitor &Visitor) const = 0;
+ virtual Error accept(MutableSectionVisitor &Visitor) = 0;
virtual void markSymbols();
virtual void
replaceSectionReferences(const DenseMap<SectionBase *, SectionBase *> &);
@@ -436,9 +436,9 @@ private:
bool operator()(const SectionBase *Lhs, const SectionBase *Rhs) const {
// Some sections might have the same address if one of them is empty. To
// fix this we can use the lexicographic ordering on ->Addr and the
- // original index.
+ // original index.
if (Lhs->OriginalOffset == Rhs->OriginalOffset)
- return Lhs->OriginalIndex < Rhs->OriginalIndex;
+ return Lhs->OriginalIndex < Rhs->OriginalIndex;
return Lhs->OriginalOffset < Rhs->OriginalOffset;
}
};
@@ -483,12 +483,12 @@ class Section : public SectionBase {
public:
explicit Section(ArrayRef<uint8_t> Data) : Contents(Data) {}
- Error accept(SectionVisitor &Visitor) const override;
- Error accept(MutableSectionVisitor &Visitor) override;
- Error removeSectionReferences(
- bool AllowBrokenLinks,
+ Error accept(SectionVisitor &Visitor) const override;
+ Error accept(MutableSectionVisitor &Visitor) override;
+ Error removeSectionReferences(
+ bool AllowBrokenLinks,
function_ref<bool(const SectionBase *)> ToRemove) override;
- Error initialize(SectionTableRef SecTable) override;
+ Error initialize(SectionTableRef SecTable) override;
void finalize() override;
};
@@ -516,8 +516,8 @@ public:
}
void appendHexData(StringRef HexData);
- Error accept(SectionVisitor &Sec) const override;
- Error accept(MutableSectionVisitor &Visitor) override;
+ Error accept(SectionVisitor &Sec) const override;
+ Error accept(MutableSectionVisitor &Visitor) override;
};
class CompressedSection : public SectionBase {
@@ -529,28 +529,28 @@ class CompressedSection : public SectionBase {
SmallVector<char, 128> CompressedData;
public:
- static Expected<CompressedSection>
- create(const SectionBase &Sec, DebugCompressionType CompressionType);
- static Expected<CompressedSection> create(ArrayRef<uint8_t> CompressedData,
- uint64_t DecompressedSize,
- uint64_t DecompressedAlign);
+ static Expected<CompressedSection>
+ create(const SectionBase &Sec, DebugCompressionType CompressionType);
+ static Expected<CompressedSection> create(ArrayRef<uint8_t> CompressedData,
+ uint64_t DecompressedSize,
+ uint64_t DecompressedAlign);
uint64_t getDecompressedSize() const { return DecompressedSize; }
uint64_t getDecompressedAlign() const { return DecompressedAlign; }
- Error accept(SectionVisitor &Visitor) const override;
- Error accept(MutableSectionVisitor &Visitor) override;
+ Error accept(SectionVisitor &Visitor) const override;
+ Error accept(MutableSectionVisitor &Visitor) override;
static bool classof(const SectionBase *S) {
return (S->OriginalFlags & ELF::SHF_COMPRESSED) ||
(StringRef(S->Name).startswith(".zdebug"));
}
-
-private:
- CompressedSection(const SectionBase &Sec,
- DebugCompressionType CompressionType, Error &Err);
- CompressedSection(ArrayRef<uint8_t> CompressedData, uint64_t DecompressedSize,
- uint64_t DecompressedAlign);
+
+private:
+ CompressedSection(const SectionBase &Sec,
+ DebugCompressionType CompressionType, Error &Err);
+ CompressedSection(ArrayRef<uint8_t> CompressedData, uint64_t DecompressedSize,
+ uint64_t DecompressedAlign);
};
class DecompressedSection : public SectionBase {
@@ -566,8 +566,8 @@ public:
Name = "." + Name.substr(2);
}
- Error accept(SectionVisitor &Visitor) const override;
- Error accept(MutableSectionVisitor &Visitor) override;
+ Error accept(SectionVisitor &Visitor) const override;
+ Error accept(MutableSectionVisitor &Visitor) override;
};
// There are two types of string tables that can exist, dynamic and not dynamic.
@@ -591,8 +591,8 @@ public:
void addString(StringRef Name);
uint32_t findIndex(StringRef Name) const;
void prepareForLayout();
- Error accept(SectionVisitor &Visitor) const override;
- Error accept(MutableSectionVisitor &Visitor) override;
+ Error accept(SectionVisitor &Visitor) const override;
+ Error accept(MutableSectionVisitor &Visitor) override;
static bool classof(const SectionBase *S) {
if (S->OriginalFlags & ELF::SHF_ALLOC)
@@ -649,18 +649,18 @@ public:
virtual ~SectionIndexSection() {}
void addIndex(uint32_t Index) {
assert(Size > 0);
- Indexes.push_back(Index);
+ Indexes.push_back(Index);
}
void reserve(size_t NumSymbols) {
Indexes.reserve(NumSymbols);
Size = NumSymbols * 4;
- }
+ }
void setSymTab(SymbolTableSection *SymTab) { Symbols = SymTab; }
- Error initialize(SectionTableRef SecTable) override;
+ Error initialize(SectionTableRef SecTable) override;
void finalize() override;
- Error accept(SectionVisitor &Visitor) const override;
- Error accept(MutableSectionVisitor &Visitor) override;
+ Error accept(SectionVisitor &Visitor) const override;
+ Error accept(MutableSectionVisitor &Visitor) override;
SectionIndexSection() {
Name = ".symtab_shndx";
@@ -698,17 +698,17 @@ public:
const SectionIndexSection *getShndxTable() const { return SectionIndexTable; }
void fillShndxTable();
const SectionBase *getStrTab() const { return SymbolNames; }
- Expected<const Symbol *> getSymbolByIndex(uint32_t Index) const;
- Expected<Symbol *> getSymbolByIndex(uint32_t Index);
+ Expected<const Symbol *> getSymbolByIndex(uint32_t Index) const;
+ Expected<Symbol *> getSymbolByIndex(uint32_t Index);
void updateSymbols(function_ref<void(Symbol &)> Callable);
- Error removeSectionReferences(
- bool AllowBrokenLinks,
+ Error removeSectionReferences(
+ bool AllowBrokenLinks,
function_ref<bool(const SectionBase *)> ToRemove) override;
- Error initialize(SectionTableRef SecTable) override;
+ Error initialize(SectionTableRef SecTable) override;
void finalize() override;
- Error accept(SectionVisitor &Visitor) const override;
- Error accept(MutableSectionVisitor &Visitor) override;
+ Error accept(SectionVisitor &Visitor) const override;
+ Error accept(MutableSectionVisitor &Visitor) override;
Error removeSymbols(function_ref<bool(const Symbol &)> ToRemove) override;
void replaceSectionReferences(
const DenseMap<SectionBase *, SectionBase *> &FromTo) override;
@@ -759,7 +759,7 @@ protected:
SymTabType *Symbols = nullptr;
public:
- Error initialize(SectionTableRef SecTable) override;
+ Error initialize(SectionTableRef SecTable) override;
void finalize() override;
};
@@ -771,10 +771,10 @@ class RelocationSection
public:
void addRelocation(Relocation Rel) { Relocations.push_back(Rel); }
- Error accept(SectionVisitor &Visitor) const override;
- Error accept(MutableSectionVisitor &Visitor) override;
- Error removeSectionReferences(
- bool AllowBrokenLinks,
+ Error accept(SectionVisitor &Visitor) const override;
+ Error accept(MutableSectionVisitor &Visitor) override;
+ Error removeSectionReferences(
+ bool AllowBrokenLinks,
function_ref<bool(const SectionBase *)> ToRemove) override;
Error removeSymbols(function_ref<bool(const Symbol &)> ToRemove) override;
void markSymbols() override;
@@ -810,8 +810,8 @@ public:
void setFlagWord(ELF::Elf32_Word W) { FlagWord = W; }
void addMember(SectionBase *Sec) { GroupMembers.push_back(Sec); }
- Error accept(SectionVisitor &) const override;
- Error accept(MutableSectionVisitor &Visitor) override;
+ Error accept(SectionVisitor &) const override;
+ Error accept(MutableSectionVisitor &Visitor) override;
void finalize() override;
Error removeSectionReferences(
bool AllowBrokenLinks,
@@ -855,8 +855,8 @@ private:
public:
explicit DynamicRelocationSection(ArrayRef<uint8_t> Data) : Contents(Data) {}
- Error accept(SectionVisitor &) const override;
- Error accept(MutableSectionVisitor &Visitor) override;
+ Error accept(SectionVisitor &) const override;
+ Error accept(MutableSectionVisitor &Visitor) override;
Error removeSectionReferences(
bool AllowBrokenLinks,
function_ref<bool(const SectionBase *)> ToRemove) override;
@@ -880,14 +880,14 @@ private:
public:
// If we add this section from an external source we can use this ctor.
explicit GnuDebugLinkSection(StringRef File, uint32_t PrecomputedCRC);
- Error accept(SectionVisitor &Visitor) const override;
- Error accept(MutableSectionVisitor &Visitor) override;
+ Error accept(SectionVisitor &Visitor) const override;
+ Error accept(MutableSectionVisitor &Visitor) override;
};
class Reader {
public:
virtual ~Reader();
- virtual Expected<std::unique_ptr<Object>> create(bool EnsureSymtab) const = 0;
+ virtual Expected<std::unique_ptr<Object>> create(bool EnsureSymtab) const = 0;
};
using object::Binary;
@@ -903,7 +903,7 @@ protected:
void initHeaderSegment();
StringTableSection *addStrTab();
SymbolTableSection *addSymTab(StringTableSection *StrTab);
- Error initSections();
+ Error initSections();
public:
BasicELFBuilder() : Obj(std::make_unique<Object>()) {}
@@ -919,7 +919,7 @@ public:
: BasicELFBuilder(), MemBuf(MB),
NewSymbolVisibility(NewSymbolVisibility) {}
- Expected<std::unique_ptr<Object>> build();
+ Expected<std::unique_ptr<Object>> build();
};
class IHexELFBuilder : public BasicELFBuilder {
@@ -931,7 +931,7 @@ public:
IHexELFBuilder(const std::vector<IHexRecord> &Records)
: BasicELFBuilder(), Records(Records) {}
- Expected<std::unique_ptr<Object>> build();
+ Expected<std::unique_ptr<Object>> build();
};
template <class ELFT> class ELFBuilder {
@@ -946,21 +946,21 @@ private:
Optional<StringRef> ExtractPartition;
void setParentSegment(Segment &Child);
- Error readProgramHeaders(const ELFFile<ELFT> &HeadersFile);
- Error initGroupSection(GroupSection *GroupSec);
- Error initSymbolTable(SymbolTableSection *SymTab);
- Error readSectionHeaders();
- Error readSections(bool EnsureSymtab);
- Error findEhdrOffset();
- Expected<SectionBase &> makeSection(const Elf_Shdr &Shdr);
+ Error readProgramHeaders(const ELFFile<ELFT> &HeadersFile);
+ Error initGroupSection(GroupSection *GroupSec);
+ Error initSymbolTable(SymbolTableSection *SymTab);
+ Error readSectionHeaders();
+ Error readSections(bool EnsureSymtab);
+ Error findEhdrOffset();
+ Expected<SectionBase &> makeSection(const Elf_Shdr &Shdr);
public:
ELFBuilder(const ELFObjectFile<ELFT> &ElfObj, Object &Obj,
Optional<StringRef> ExtractPartition)
- : ElfFile(ElfObj.getELFFile()), Obj(Obj),
+ : ElfFile(ElfObj.getELFFile()), Obj(Obj),
ExtractPartition(ExtractPartition) {}
- Error build(bool EnsureSymtab);
+ Error build(bool EnsureSymtab);
};
class BinaryReader : public Reader {
@@ -970,7 +970,7 @@ class BinaryReader : public Reader {
public:
BinaryReader(MemoryBuffer *MB, const uint8_t NewSymbolVisibility)
: MemBuf(MB), NewSymbolVisibility(NewSymbolVisibility) {}
- Expected<std::unique_ptr<Object>> create(bool EnsureSymtab) const override;
+ Expected<std::unique_ptr<Object>> create(bool EnsureSymtab) const override;
};
class IHexReader : public Reader {
@@ -992,7 +992,7 @@ class IHexReader : public Reader {
public:
IHexReader(MemoryBuffer *MB) : MemBuf(MB) {}
- Expected<std::unique_ptr<Object>> create(bool EnsureSymtab) const override;
+ Expected<std::unique_ptr<Object>> create(bool EnsureSymtab) const override;
};
class ELFReader : public Reader {
@@ -1000,7 +1000,7 @@ class ELFReader : public Reader {
Optional<StringRef> ExtractPartition;
public:
- Expected<std::unique_ptr<Object>> create(bool EnsureSymtab) const override;
+ Expected<std::unique_ptr<Object>> create(bool EnsureSymtab) const override;
explicit ELFReader(Binary *B, Optional<StringRef> ExtractPartition)
: Bin(B), ExtractPartition(ExtractPartition) {}
};
@@ -1084,7 +1084,7 @@ public:
Ptr->Index = Sections.size();
return *Ptr;
}
- Error addNewSymbolTable();
+ Error addNewSymbolTable();
Segment &addSegment(ArrayRef<uint8_t> Data) {
Segments.emplace_back(std::make_unique<Segment>(Data));
return *Segments.back();
diff --git a/contrib/libs/llvm12/tools/llvm-objcopy/InstallNameToolOpts.td b/contrib/libs/llvm12/tools/llvm-objcopy/InstallNameToolOpts.td
index 88dea84400..6444425f2d 100644
--- a/contrib/libs/llvm12/tools/llvm-objcopy/InstallNameToolOpts.td
+++ b/contrib/libs/llvm12/tools/llvm-objcopy/InstallNameToolOpts.td
@@ -18,15 +18,15 @@ def h : Flag<["-"], "h">, Alias<help>;
def add_rpath : Option<["-", "--"], "add_rpath", KIND_SEPARATE>,
HelpText<"Add new rpath">;
-def prepend_rpath : Option<["-", "--"], "prepend_rpath", KIND_SEPARATE>,
- HelpText<"Add new rpath before other rpaths">;
-
+def prepend_rpath : Option<["-", "--"], "prepend_rpath", KIND_SEPARATE>,
+ HelpText<"Add new rpath before other rpaths">;
+
def delete_rpath: Option<["-", "--"], "delete_rpath", KIND_SEPARATE>,
HelpText<"Delete specified rpath">;
-def delete_all_rpaths: Flag<["-", "--"], "delete_all_rpaths">,
- HelpText<"Delete all rpath directives">;
-
+def delete_all_rpaths: Flag<["-", "--"], "delete_all_rpaths">,
+ HelpText<"Delete all rpath directives">;
+
def rpath: MultiArg<["-", "--"], "rpath", 2>,
HelpText<"Change rpath path name">;
@@ -38,7 +38,7 @@ def change: MultiArg<["-", "--"], "change", 2>,
def version : Flag<["--"], "version">,
HelpText<"Print the version and exit.">;
-
-def V : Flag<["-"], "V">,
- Alias<version>,
- HelpText<"Alias for --version">;
+
+def V : Flag<["-"], "V">,
+ Alias<version>,
+ HelpText<"Alias for --version">;
diff --git a/contrib/libs/llvm12/tools/llvm-objcopy/MachO/MachOLayoutBuilder.cpp b/contrib/libs/llvm12/tools/llvm-objcopy/MachO/MachOLayoutBuilder.cpp
index 8e2bf36238..849a1e4ea4 100644
--- a/contrib/libs/llvm12/tools/llvm-objcopy/MachO/MachOLayoutBuilder.cpp
+++ b/contrib/libs/llvm12/tools/llvm-objcopy/MachO/MachOLayoutBuilder.cpp
@@ -15,14 +15,14 @@ namespace llvm {
namespace objcopy {
namespace macho {
-StringTableBuilder::Kind
-MachOLayoutBuilder::getStringTableBuilderKind(const Object &O, bool Is64Bit) {
- if (O.Header.FileType == MachO::HeaderFileType::MH_OBJECT)
- return Is64Bit ? StringTableBuilder::MachO64 : StringTableBuilder::MachO;
- return Is64Bit ? StringTableBuilder::MachO64Linked
- : StringTableBuilder::MachOLinked;
-}
-
+StringTableBuilder::Kind
+MachOLayoutBuilder::getStringTableBuilderKind(const Object &O, bool Is64Bit) {
+ if (O.Header.FileType == MachO::HeaderFileType::MH_OBJECT)
+ return Is64Bit ? StringTableBuilder::MachO64 : StringTableBuilder::MachO;
+ return Is64Bit ? StringTableBuilder::MachO64Linked
+ : StringTableBuilder::MachOLinked;
+}
+
uint32_t MachOLayoutBuilder::computeSizeOfCmds() const {
uint32_t Size = 0;
for (const LoadCommand &LC : O.LoadCommands) {
@@ -156,7 +156,7 @@ uint64_t MachOLayoutBuilder::layoutSegments() {
"Section's address cannot be smaller than Segment's one");
uint32_t SectOffset = Sec->Addr - SegmentVmAddr;
if (IsObjectFile) {
- if (!Sec->hasValidOffset()) {
+ if (!Sec->hasValidOffset()) {
Sec->Offset = 0;
} else {
uint64_t PaddingSize =
@@ -166,7 +166,7 @@ uint64_t MachOLayoutBuilder::layoutSegments() {
SegFileSize += PaddingSize + Sec->Size;
}
} else {
- if (!Sec->hasValidOffset()) {
+ if (!Sec->hasValidOffset()) {
Sec->Offset = 0;
} else {
Sec->Offset = SegOffset + SectOffset;
@@ -260,8 +260,8 @@ Error MachOLayoutBuilder::layoutTail(uint64_t Offset) {
sizeof(uint32_t) * O.IndirectSymTable.Symbols.size();
uint64_t StartOfCodeSignature =
StartOfSymbolStrings + StrTableBuilder.getSize();
- if (O.CodeSignatureCommandIndex)
- StartOfCodeSignature = alignTo(StartOfCodeSignature, 16);
+ if (O.CodeSignatureCommandIndex)
+ StartOfCodeSignature = alignTo(StartOfCodeSignature, 16);
uint64_t LinkEditSize =
(StartOfCodeSignature + O.CodeSignature.Data.size()) - StartOfLinkEdit;
diff --git a/contrib/libs/llvm12/tools/llvm-objcopy/MachO/MachOLayoutBuilder.h b/contrib/libs/llvm12/tools/llvm-objcopy/MachO/MachOLayoutBuilder.h
index 5fe6683e27..3b8d81cdf3 100644
--- a/contrib/libs/llvm12/tools/llvm-objcopy/MachO/MachOLayoutBuilder.h
+++ b/contrib/libs/llvm12/tools/llvm-objcopy/MachO/MachOLayoutBuilder.h
@@ -23,7 +23,7 @@ class MachOLayoutBuilder {
// Points to the __LINKEDIT segment if it exists.
MachO::macho_load_command *LinkEditLoadCommand = nullptr;
- StringTableBuilder StrTableBuilder;
+ StringTableBuilder StrTableBuilder;
uint32_t computeSizeOfCmds() const;
void constructStringTable();
@@ -33,13 +33,13 @@ class MachOLayoutBuilder {
uint64_t layoutRelocations(uint64_t Offset);
Error layoutTail(uint64_t Offset);
- static StringTableBuilder::Kind getStringTableBuilderKind(const Object &O,
- bool Is64Bit);
-
+ static StringTableBuilder::Kind getStringTableBuilderKind(const Object &O,
+ bool Is64Bit);
+
public:
MachOLayoutBuilder(Object &O, bool Is64Bit, uint64_t PageSize)
- : O(O), Is64Bit(Is64Bit), PageSize(PageSize),
- StrTableBuilder(getStringTableBuilderKind(O, Is64Bit)) {}
+ : O(O), Is64Bit(Is64Bit), PageSize(PageSize),
+ StrTableBuilder(getStringTableBuilderKind(O, Is64Bit)) {}
// Recomputes and updates fields in the given object such as file offsets.
Error layout();
diff --git a/contrib/libs/llvm12/tools/llvm-objcopy/MachO/MachOObjcopy.cpp b/contrib/libs/llvm12/tools/llvm-objcopy/MachO/MachOObjcopy.cpp
index fef4a0ae55..2af5b116d1 100644
--- a/contrib/libs/llvm12/tools/llvm-objcopy/MachO/MachOObjcopy.cpp
+++ b/contrib/libs/llvm12/tools/llvm-objcopy/MachO/MachOObjcopy.cpp
@@ -8,13 +8,13 @@
#include "MachOObjcopy.h"
#include "../CopyConfig.h"
-#include "../llvm-objcopy.h"
+#include "../llvm-objcopy.h"
#include "MachOReader.h"
#include "MachOWriter.h"
#include "llvm/ADT/DenseSet.h"
-#include "llvm/Object/ArchiveWriter.h"
-#include "llvm/Object/MachOUniversal.h"
-#include "llvm/Object/MachOUniversalWriter.h"
+#include "llvm/Object/ArchiveWriter.h"
+#include "llvm/Object/MachOUniversal.h"
+#include "llvm/Object/MachOUniversalWriter.h"
#include "llvm/Support/Errc.h"
#include "llvm/Support/Error.h"
@@ -137,14 +137,14 @@ static Error processLoadCommands(const CopyConfig &Config, Object &Obj) {
DenseSet<StringRef> RPathsToRemove(Config.RPathsToRemove.begin(),
Config.RPathsToRemove.end());
- LoadCommandPred RemovePred = [&RPathsToRemove,
- &Config](const LoadCommand &LC) {
+ LoadCommandPred RemovePred = [&RPathsToRemove,
+ &Config](const LoadCommand &LC) {
if (LC.MachOLoadCommand.load_command_data.cmd == MachO::LC_RPATH) {
- // When removing all RPaths we don't need to care
- // about what it contains
- if (Config.RemoveAllRpaths)
- return true;
-
+ // When removing all RPaths we don't need to care
+ // about what it contains
+ if (Config.RemoveAllRpaths)
+ return true;
+
StringRef RPath = getPayloadString(LC);
if (RPathsToRemove.count(RPath)) {
RPathsToRemove.erase(RPath);
@@ -178,22 +178,22 @@ static Error processLoadCommands(const CopyConfig &Config, Object &Obj) {
for (const auto &OldNew : Config.RPathsToUpdate) {
StringRef Old = OldNew.getFirst();
StringRef New = OldNew.getSecond();
- if (!RPaths.contains(Old))
+ if (!RPaths.contains(Old))
return createStringError(errc::invalid_argument,
"no LC_RPATH load command with path: " + Old);
- if (RPaths.contains(New))
+ if (RPaths.contains(New))
return createStringError(errc::invalid_argument,
- "rpath '" + New +
- "' would create a duplicate load command");
+ "rpath '" + New +
+ "' would create a duplicate load command");
}
// Update load commands.
for (LoadCommand &LC : Obj.LoadCommands) {
switch (LC.MachOLoadCommand.load_command_data.cmd) {
case MachO::LC_ID_DYLIB:
- if (Config.SharedLibId)
- updateLoadCommandPayloadString<MachO::dylib_command>(
- LC, *Config.SharedLibId);
+ if (Config.SharedLibId)
+ updateLoadCommandPayloadString<MachO::dylib_command>(
+ LC, *Config.SharedLibId);
break;
case MachO::LC_RPATH: {
@@ -220,30 +220,30 @@ static Error processLoadCommands(const CopyConfig &Config, Object &Obj) {
// Add new RPaths.
for (StringRef RPath : Config.RPathToAdd) {
- if (RPaths.contains(RPath))
- return createStringError(errc::invalid_argument,
- "rpath '" + RPath +
- "' would create a duplicate load command");
- RPaths.insert(RPath);
- Obj.LoadCommands.push_back(buildRPathLoadCommand(RPath));
- }
-
- for (StringRef RPath : Config.RPathToPrepend) {
- if (RPaths.contains(RPath))
+ if (RPaths.contains(RPath))
return createStringError(errc::invalid_argument,
- "rpath '" + RPath +
- "' would create a duplicate load command");
-
+ "rpath '" + RPath +
+ "' would create a duplicate load command");
RPaths.insert(RPath);
- Obj.LoadCommands.insert(Obj.LoadCommands.begin(),
- buildRPathLoadCommand(RPath));
+ Obj.LoadCommands.push_back(buildRPathLoadCommand(RPath));
}
- // Unlike appending rpaths, the indexes of subsequent load commands must
- // be recalculated after prepending one.
- if (!Config.RPathToPrepend.empty())
- Obj.updateLoadCommandIndexes();
-
+ for (StringRef RPath : Config.RPathToPrepend) {
+ if (RPaths.contains(RPath))
+ return createStringError(errc::invalid_argument,
+ "rpath '" + RPath +
+ "' would create a duplicate load command");
+
+ RPaths.insert(RPath);
+ Obj.LoadCommands.insert(Obj.LoadCommands.begin(),
+ buildRPathLoadCommand(RPath));
+ }
+
+ // Unlike appending rpaths, the indexes of subsequent load commands must
+ // be recalculated after prepending one.
+ if (!Config.RPathToPrepend.empty())
+ Obj.updateLoadCommandIndexes();
+
return Error::success();
}
@@ -280,34 +280,34 @@ static Error addSection(StringRef SecName, StringRef Filename, Object &Obj) {
StringRef TargetSegName = Pair.first;
Section Sec(TargetSegName, Pair.second);
Sec.Content = Obj.NewSectionsContents.save(Buf->getBuffer());
- Sec.Size = Sec.Content.size();
+ Sec.Size = Sec.Content.size();
// Add the a section into an existing segment.
for (LoadCommand &LC : Obj.LoadCommands) {
Optional<StringRef> SegName = LC.getSegmentName();
if (SegName && SegName == TargetSegName) {
- uint64_t Addr = *LC.getSegmentVMAddr();
- for (const std::unique_ptr<Section> &S : LC.Sections)
- Addr = std::max(Addr, S->Addr + S->Size);
+ uint64_t Addr = *LC.getSegmentVMAddr();
+ for (const std::unique_ptr<Section> &S : LC.Sections)
+ Addr = std::max(Addr, S->Addr + S->Size);
LC.Sections.push_back(std::make_unique<Section>(Sec));
- LC.Sections.back()->Addr = Addr;
+ LC.Sections.back()->Addr = Addr;
return Error::success();
}
}
// There's no segment named TargetSegName. Create a new load command and
// Insert a new section into it.
- LoadCommand &NewSegment =
- Obj.addSegment(TargetSegName, alignTo(Sec.Size, 16384));
+ LoadCommand &NewSegment =
+ Obj.addSegment(TargetSegName, alignTo(Sec.Size, 16384));
NewSegment.Sections.push_back(std::make_unique<Section>(Sec));
- NewSegment.Sections.back()->Addr = *NewSegment.getSegmentVMAddr();
+ NewSegment.Sections.back()->Addr = *NewSegment.getSegmentVMAddr();
return Error::success();
}
// isValidMachOCannonicalName returns success if Name is a MachO cannonical name
// ("<segment>,<section>") and lengths of both segment and section names are
// valid.
-static Error isValidMachOCannonicalName(StringRef Name) {
+static Error isValidMachOCannonicalName(StringRef Name) {
if (Name.count(',') != 1)
return createStringError(errc::invalid_argument,
"invalid section name '%s' (should be formatted "
@@ -340,7 +340,7 @@ static Error handleArgs(const CopyConfig &Config, Object &Obj) {
Config.ExtractDWO || Config.LocalizeHidden || Config.PreserveDates ||
Config.StripAllGNU || Config.StripDWO || Config.StripNonAlloc ||
Config.StripSections || Config.Weaken || Config.DecompressDebugSections ||
- Config.StripUnneeded || Config.DiscardMode == DiscardType::Locals ||
+ Config.StripUnneeded || Config.DiscardMode == DiscardType::Locals ||
!Config.SymbolsToAdd.empty() || Config.EntryExpr) {
return createStringError(llvm::errc::invalid_argument,
"option not supported by llvm-objcopy for MachO");
@@ -388,11 +388,11 @@ static Error handleArgs(const CopyConfig &Config, Object &Obj) {
Error executeObjcopyOnBinary(const CopyConfig &Config,
object::MachOObjectFile &In, Buffer &Out) {
MachOReader Reader(In);
- Expected<std::unique_ptr<Object>> O = Reader.create();
+ Expected<std::unique_ptr<Object>> O = Reader.create();
if (!O)
- return createFileError(Config.InputFilename, O.takeError());
+ return createFileError(Config.InputFilename, O.takeError());
- if (Error E = handleArgs(Config, **O))
+ if (Error E = handleArgs(Config, **O))
return createFileError(Config.InputFilename, std::move(E));
// Page size used for alignment of segment sizes in Mach-O executables and
@@ -408,81 +408,81 @@ Error executeObjcopyOnBinary(const CopyConfig &Config,
PageSize = 4096;
}
- MachOWriter Writer(**O, In.is64Bit(), In.isLittleEndian(), PageSize, Out);
+ MachOWriter Writer(**O, In.is64Bit(), In.isLittleEndian(), PageSize, Out);
if (auto E = Writer.finalize())
return E;
return Writer.write();
}
-Error executeObjcopyOnMachOUniversalBinary(CopyConfig &Config,
- const MachOUniversalBinary &In,
- Buffer &Out) {
- SmallVector<OwningBinary<Binary>, 2> Binaries;
- SmallVector<Slice, 2> Slices;
- for (const auto &O : In.objects()) {
- Expected<std::unique_ptr<Archive>> ArOrErr = O.getAsArchive();
- if (ArOrErr) {
- Expected<std::vector<NewArchiveMember>> NewArchiveMembersOrErr =
- createNewArchiveMembers(Config, **ArOrErr);
- if (!NewArchiveMembersOrErr)
- return NewArchiveMembersOrErr.takeError();
- Expected<std::unique_ptr<MemoryBuffer>> OutputBufferOrErr =
- writeArchiveToBuffer(*NewArchiveMembersOrErr,
- (*ArOrErr)->hasSymbolTable(), (*ArOrErr)->kind(),
- Config.DeterministicArchives,
- (*ArOrErr)->isThin());
- if (!OutputBufferOrErr)
- return OutputBufferOrErr.takeError();
- Expected<std::unique_ptr<Binary>> BinaryOrErr =
- object::createBinary(**OutputBufferOrErr);
- if (!BinaryOrErr)
- return BinaryOrErr.takeError();
- Binaries.emplace_back(std::move(*BinaryOrErr),
- std::move(*OutputBufferOrErr));
- Slices.emplace_back(*cast<Archive>(Binaries.back().getBinary()),
- O.getCPUType(), O.getCPUSubType(),
- O.getArchFlagName(), O.getAlign());
- continue;
- }
- // The methods getAsArchive, getAsObjectFile, getAsIRObject of the class
- // ObjectForArch return an Error in case of the type mismatch. We need to
- // check each in turn to see what kind of slice this is, so ignore errors
- // produced along the way.
- consumeError(ArOrErr.takeError());
-
- Expected<std::unique_ptr<MachOObjectFile>> ObjOrErr = O.getAsObjectFile();
- if (!ObjOrErr) {
- consumeError(ObjOrErr.takeError());
- return createStringError(std::errc::invalid_argument,
- "slice for '%s' of the universal Mach-O binary "
- "'%s' is not a Mach-O object or an archive",
- O.getArchFlagName().c_str(),
- Config.InputFilename.str().c_str());
- }
- std::string ArchFlagName = O.getArchFlagName();
- MemBuffer MB(ArchFlagName);
- if (Error E = executeObjcopyOnBinary(Config, **ObjOrErr, MB))
- return E;
- std::unique_ptr<WritableMemoryBuffer> OutputBuffer =
- MB.releaseMemoryBuffer();
- Expected<std::unique_ptr<Binary>> BinaryOrErr =
- object::createBinary(*OutputBuffer);
- if (!BinaryOrErr)
- return BinaryOrErr.takeError();
- Binaries.emplace_back(std::move(*BinaryOrErr), std::move(OutputBuffer));
- Slices.emplace_back(*cast<MachOObjectFile>(Binaries.back().getBinary()),
- O.getAlign());
- }
- Expected<std::unique_ptr<MemoryBuffer>> B =
- writeUniversalBinaryToBuffer(Slices);
- if (!B)
- return B.takeError();
- if (Error E = Out.allocate((*B)->getBufferSize()))
- return E;
- memcpy(Out.getBufferStart(), (*B)->getBufferStart(), (*B)->getBufferSize());
- return Out.commit();
-}
-
+Error executeObjcopyOnMachOUniversalBinary(CopyConfig &Config,
+ const MachOUniversalBinary &In,
+ Buffer &Out) {
+ SmallVector<OwningBinary<Binary>, 2> Binaries;
+ SmallVector<Slice, 2> Slices;
+ for (const auto &O : In.objects()) {
+ Expected<std::unique_ptr<Archive>> ArOrErr = O.getAsArchive();
+ if (ArOrErr) {
+ Expected<std::vector<NewArchiveMember>> NewArchiveMembersOrErr =
+ createNewArchiveMembers(Config, **ArOrErr);
+ if (!NewArchiveMembersOrErr)
+ return NewArchiveMembersOrErr.takeError();
+ Expected<std::unique_ptr<MemoryBuffer>> OutputBufferOrErr =
+ writeArchiveToBuffer(*NewArchiveMembersOrErr,
+ (*ArOrErr)->hasSymbolTable(), (*ArOrErr)->kind(),
+ Config.DeterministicArchives,
+ (*ArOrErr)->isThin());
+ if (!OutputBufferOrErr)
+ return OutputBufferOrErr.takeError();
+ Expected<std::unique_ptr<Binary>> BinaryOrErr =
+ object::createBinary(**OutputBufferOrErr);
+ if (!BinaryOrErr)
+ return BinaryOrErr.takeError();
+ Binaries.emplace_back(std::move(*BinaryOrErr),
+ std::move(*OutputBufferOrErr));
+ Slices.emplace_back(*cast<Archive>(Binaries.back().getBinary()),
+ O.getCPUType(), O.getCPUSubType(),
+ O.getArchFlagName(), O.getAlign());
+ continue;
+ }
+ // The methods getAsArchive, getAsObjectFile, getAsIRObject of the class
+ // ObjectForArch return an Error in case of the type mismatch. We need to
+ // check each in turn to see what kind of slice this is, so ignore errors
+ // produced along the way.
+ consumeError(ArOrErr.takeError());
+
+ Expected<std::unique_ptr<MachOObjectFile>> ObjOrErr = O.getAsObjectFile();
+ if (!ObjOrErr) {
+ consumeError(ObjOrErr.takeError());
+ return createStringError(std::errc::invalid_argument,
+ "slice for '%s' of the universal Mach-O binary "
+ "'%s' is not a Mach-O object or an archive",
+ O.getArchFlagName().c_str(),
+ Config.InputFilename.str().c_str());
+ }
+ std::string ArchFlagName = O.getArchFlagName();
+ MemBuffer MB(ArchFlagName);
+ if (Error E = executeObjcopyOnBinary(Config, **ObjOrErr, MB))
+ return E;
+ std::unique_ptr<WritableMemoryBuffer> OutputBuffer =
+ MB.releaseMemoryBuffer();
+ Expected<std::unique_ptr<Binary>> BinaryOrErr =
+ object::createBinary(*OutputBuffer);
+ if (!BinaryOrErr)
+ return BinaryOrErr.takeError();
+ Binaries.emplace_back(std::move(*BinaryOrErr), std::move(OutputBuffer));
+ Slices.emplace_back(*cast<MachOObjectFile>(Binaries.back().getBinary()),
+ O.getAlign());
+ }
+ Expected<std::unique_ptr<MemoryBuffer>> B =
+ writeUniversalBinaryToBuffer(Slices);
+ if (!B)
+ return B.takeError();
+ if (Error E = Out.allocate((*B)->getBufferSize()))
+ return E;
+ memcpy(Out.getBufferStart(), (*B)->getBufferStart(), (*B)->getBufferSize());
+ return Out.commit();
+}
+
} // end namespace macho
} // end namespace objcopy
} // end namespace llvm
diff --git a/contrib/libs/llvm12/tools/llvm-objcopy/MachO/MachOObjcopy.h b/contrib/libs/llvm12/tools/llvm-objcopy/MachO/MachOObjcopy.h
index c3f5391f79..e79db34e8b 100644
--- a/contrib/libs/llvm12/tools/llvm-objcopy/MachO/MachOObjcopy.h
+++ b/contrib/libs/llvm12/tools/llvm-objcopy/MachO/MachOObjcopy.h
@@ -24,10 +24,10 @@ class Buffer;
namespace macho {
Error executeObjcopyOnBinary(const CopyConfig &Config,
object::MachOObjectFile &In, Buffer &Out);
-
-Error executeObjcopyOnMachOUniversalBinary(
- CopyConfig &Config, const object::MachOUniversalBinary &In, Buffer &Out);
-
+
+Error executeObjcopyOnMachOUniversalBinary(
+ CopyConfig &Config, const object::MachOUniversalBinary &In, Buffer &Out);
+
} // end namespace macho
} // end namespace objcopy
} // end namespace llvm
diff --git a/contrib/libs/llvm12/tools/llvm-objcopy/MachO/MachOReader.cpp b/contrib/libs/llvm12/tools/llvm-objcopy/MachO/MachOReader.cpp
index 548a85bd49..495d54046f 100644
--- a/contrib/libs/llvm12/tools/llvm-objcopy/MachO/MachOReader.cpp
+++ b/contrib/libs/llvm12/tools/llvm-objcopy/MachO/MachOReader.cpp
@@ -10,7 +10,7 @@
#include "Object.h"
#include "llvm/BinaryFormat/MachO.h"
#include "llvm/Object/MachO.h"
-#include "llvm/Support/Errc.h"
+#include "llvm/Support/Errc.h"
#include <memory>
namespace llvm {
@@ -35,7 +35,7 @@ Section constructSectionCommon(SectionType Sec, uint32_t Index) {
S.Index = Index;
S.Addr = Sec.addr;
S.Size = Sec.size;
- S.OriginalOffset = Sec.offset;
+ S.OriginalOffset = Sec.offset;
S.Align = Sec.align;
S.RelOff = Sec.reloff;
S.NReloc = Sec.nreloc;
@@ -60,7 +60,7 @@ template <> Section constructSection(MachO::section_64 Sec, uint32_t Index) {
}
template <typename SectionType, typename SegmentType>
-Expected<std::vector<std::unique_ptr<Section>>>
+Expected<std::vector<std::unique_ptr<Section>>>
extractSections(const object::MachOObjectFile::LoadCommandInfo &LoadCmd,
const object::MachOObjectFile &MachOObj,
uint32_t &NextSectionIndex) {
@@ -85,16 +85,16 @@ extractSections(const object::MachOObjectFile::LoadCommandInfo &LoadCmd,
Expected<object::SectionRef> SecRef =
MachOObj.getSection(NextSectionIndex++);
if (!SecRef)
- return SecRef.takeError();
+ return SecRef.takeError();
- Expected<ArrayRef<uint8_t>> Data =
- MachOObj.getSectionContents(SecRef->getRawDataRefImpl());
- if (!Data)
- return Data.takeError();
-
- S.Content =
- StringRef(reinterpret_cast<const char *>(Data->data()), Data->size());
+ Expected<ArrayRef<uint8_t>> Data =
+ MachOObj.getSectionContents(SecRef->getRawDataRefImpl());
+ if (!Data)
+ return Data.takeError();
+ S.Content =
+ StringRef(reinterpret_cast<const char *>(Data->data()), Data->size());
+
S.Relocations.reserve(S.NReloc);
for (auto RI = MachOObj.section_rel_begin(SecRef->getRawDataRefImpl()),
RE = MachOObj.section_rel_end(SecRef->getRawDataRefImpl());
@@ -110,10 +110,10 @@ extractSections(const object::MachOObjectFile::LoadCommandInfo &LoadCmd,
assert(S.NReloc == S.Relocations.size() &&
"Incorrect number of relocations");
}
- return std::move(Sections);
+ return std::move(Sections);
}
-Error MachOReader::readLoadCommands(Object &O) const {
+Error MachOReader::readLoadCommands(Object &O) const {
// For MachO sections indices start from 1.
uint32_t NextSectionIndex = 1;
for (auto LoadCmd : MachOObj.load_commands()) {
@@ -123,20 +123,20 @@ Error MachOReader::readLoadCommands(Object &O) const {
O.CodeSignatureCommandIndex = O.LoadCommands.size();
break;
case MachO::LC_SEGMENT:
- if (Expected<std::vector<std::unique_ptr<Section>>> Sections =
- extractSections<MachO::section, MachO::segment_command>(
- LoadCmd, MachOObj, NextSectionIndex))
- LC.Sections = std::move(*Sections);
- else
- return Sections.takeError();
+ if (Expected<std::vector<std::unique_ptr<Section>>> Sections =
+ extractSections<MachO::section, MachO::segment_command>(
+ LoadCmd, MachOObj, NextSectionIndex))
+ LC.Sections = std::move(*Sections);
+ else
+ return Sections.takeError();
break;
case MachO::LC_SEGMENT_64:
- if (Expected<std::vector<std::unique_ptr<Section>>> Sections =
- extractSections<MachO::section_64, MachO::segment_command_64>(
- LoadCmd, MachOObj, NextSectionIndex))
- LC.Sections = std::move(*Sections);
- else
- return Sections.takeError();
+ if (Expected<std::vector<std::unique_ptr<Section>>> Sections =
+ extractSections<MachO::section_64, MachO::segment_command_64>(
+ LoadCmd, MachOObj, NextSectionIndex))
+ LC.Sections = std::move(*Sections);
+ else
+ return Sections.takeError();
break;
case MachO::LC_SYMTAB:
O.SymTabCommandIndex = O.LoadCommands.size();
@@ -184,7 +184,7 @@ Error MachOReader::readLoadCommands(Object &O) const {
}
O.LoadCommands.push_back(std::move(LC));
}
- return Error::success();
+ return Error::success();
}
template <typename nlist_t>
@@ -316,11 +316,11 @@ void MachOReader::readSwiftVersion(Object &O) const {
}
}
-Expected<std::unique_ptr<Object>> MachOReader::create() const {
+Expected<std::unique_ptr<Object>> MachOReader::create() const {
auto Obj = std::make_unique<Object>();
readHeader(*Obj);
- if (Error E = readLoadCommands(*Obj))
- return std::move(E);
+ if (Error E = readLoadCommands(*Obj))
+ return std::move(E);
readSymbolTable(*Obj);
setSymbolInRelocationInfo(*Obj);
readRebaseInfo(*Obj);
@@ -333,7 +333,7 @@ Expected<std::unique_ptr<Object>> MachOReader::create() const {
readFunctionStartsData(*Obj);
readIndirectSymbolTable(*Obj);
readSwiftVersion(*Obj);
- return std::move(Obj);
+ return std::move(Obj);
}
} // end namespace macho
diff --git a/contrib/libs/llvm12/tools/llvm-objcopy/MachO/MachOReader.h b/contrib/libs/llvm12/tools/llvm-objcopy/MachO/MachOReader.h
index b446e02865..c42e58d0da 100644
--- a/contrib/libs/llvm12/tools/llvm-objcopy/MachO/MachOReader.h
+++ b/contrib/libs/llvm12/tools/llvm-objcopy/MachO/MachOReader.h
@@ -21,14 +21,14 @@ namespace macho {
class Reader {
public:
virtual ~Reader(){};
- virtual Expected<std::unique_ptr<Object>> create() const = 0;
+ virtual Expected<std::unique_ptr<Object>> create() const = 0;
};
class MachOReader : public Reader {
const object::MachOObjectFile &MachOObj;
void readHeader(Object &O) const;
- Error readLoadCommands(Object &O) const;
+ Error readLoadCommands(Object &O) const;
void readSymbolTable(Object &O) const;
void setSymbolInRelocationInfo(Object &O) const;
void readRebaseInfo(Object &O) const;
@@ -46,7 +46,7 @@ class MachOReader : public Reader {
public:
explicit MachOReader(const object::MachOObjectFile &Obj) : MachOObj(Obj) {}
- Expected<std::unique_ptr<Object>> create() const override;
+ Expected<std::unique_ptr<Object>> create() const override;
};
} // end namespace macho
diff --git a/contrib/libs/llvm12/tools/llvm-objcopy/MachO/MachOWriter.cpp b/contrib/libs/llvm12/tools/llvm-objcopy/MachO/MachOWriter.cpp
index 56dd08df3b..7ff05ed9e0 100644
--- a/contrib/libs/llvm12/tools/llvm-objcopy/MachO/MachOWriter.cpp
+++ b/contrib/libs/llvm12/tools/llvm-objcopy/MachO/MachOWriter.cpp
@@ -121,14 +121,14 @@ size_t MachOWriter::totalSize() const {
// Otherwise, use the last section / reloction.
for (const LoadCommand &LC : O.LoadCommands)
for (const std::unique_ptr<Section> &S : LC.Sections) {
- if (!S->hasValidOffset()) {
- assert((S->Offset == 0) && "Skipped section's offset must be zero");
- assert((S->isVirtualSection() || S->Size == 0) &&
- "Non-zero-fill sections with zero offset must have zero size");
- continue;
- }
- assert((S->Offset != 0) &&
- "Non-zero-fill section's offset cannot be zero");
+ if (!S->hasValidOffset()) {
+ assert((S->Offset == 0) && "Skipped section's offset must be zero");
+ assert((S->isVirtualSection() || S->Size == 0) &&
+ "Non-zero-fill sections with zero offset must have zero size");
+ continue;
+ }
+ assert((S->Offset != 0) &&
+ "Non-zero-fill section's offset cannot be zero");
Ends.push_back(S->Offset + S->Size);
if (S->RelOff)
Ends.push_back(S->RelOff +
@@ -248,12 +248,12 @@ void MachOWriter::writeSectionInLoadCommand(const Section &Sec, uint8_t *&Out) {
void MachOWriter::writeSections() {
for (const LoadCommand &LC : O.LoadCommands)
for (const std::unique_ptr<Section> &Sec : LC.Sections) {
- if (!Sec->hasValidOffset()) {
- assert((Sec->Offset == 0) && "Skipped section's offset must be zero");
- assert((Sec->isVirtualSection() || Sec->Size == 0) &&
- "Non-zero-fill sections with zero offset must have zero size");
+ if (!Sec->hasValidOffset()) {
+ assert((Sec->Offset == 0) && "Skipped section's offset must be zero");
+ assert((Sec->isVirtualSection() || Sec->Size == 0) &&
+ "Non-zero-fill sections with zero offset must have zero size");
continue;
- }
+ }
assert(Sec->Offset && "Section offset can not be zero");
assert((Sec->Size == Sec->Content.size()) && "Incorrect section size");
diff --git a/contrib/libs/llvm12/tools/llvm-objcopy/MachO/Object.cpp b/contrib/libs/llvm12/tools/llvm-objcopy/MachO/Object.cpp
index cdb97531fb..1f7e04c14e 100644
--- a/contrib/libs/llvm12/tools/llvm-objcopy/MachO/Object.cpp
+++ b/contrib/libs/llvm12/tools/llvm-objcopy/MachO/Object.cpp
@@ -26,7 +26,7 @@ SymbolEntry *SymbolTable::getSymbolByIndex(uint32_t Index) {
void SymbolTable::removeSymbols(
function_ref<bool(const std::unique_ptr<SymbolEntry> &)> ToRemove) {
- llvm::erase_if(Symbols, ToRemove);
+ llvm::erase_if(Symbols, ToRemove);
}
void Object::updateLoadCommandIndexes() {
@@ -108,54 +108,54 @@ Error Object::removeSections(
return Error::success();
}
-uint64_t Object::nextAvailableSegmentAddress() const {
- uint64_t HeaderSize =
- is64Bit() ? sizeof(MachO::mach_header_64) : sizeof(MachO::mach_header);
- uint64_t Addr = HeaderSize + Header.SizeOfCmds;
- for (const LoadCommand &LC : LoadCommands) {
- const MachO::macho_load_command &MLC = LC.MachOLoadCommand;
- switch (MLC.load_command_data.cmd) {
- case MachO::LC_SEGMENT:
- Addr = std::max(Addr,
- static_cast<uint64_t>(MLC.segment_command_data.vmaddr) +
- MLC.segment_command_data.vmsize);
- break;
- case MachO::LC_SEGMENT_64:
- Addr = std::max(Addr, MLC.segment_command_64_data.vmaddr +
- MLC.segment_command_64_data.vmsize);
- break;
- default:
- continue;
- }
- }
- return Addr;
+uint64_t Object::nextAvailableSegmentAddress() const {
+ uint64_t HeaderSize =
+ is64Bit() ? sizeof(MachO::mach_header_64) : sizeof(MachO::mach_header);
+ uint64_t Addr = HeaderSize + Header.SizeOfCmds;
+ for (const LoadCommand &LC : LoadCommands) {
+ const MachO::macho_load_command &MLC = LC.MachOLoadCommand;
+ switch (MLC.load_command_data.cmd) {
+ case MachO::LC_SEGMENT:
+ Addr = std::max(Addr,
+ static_cast<uint64_t>(MLC.segment_command_data.vmaddr) +
+ MLC.segment_command_data.vmsize);
+ break;
+ case MachO::LC_SEGMENT_64:
+ Addr = std::max(Addr, MLC.segment_command_64_data.vmaddr +
+ MLC.segment_command_64_data.vmsize);
+ break;
+ default:
+ continue;
+ }
+ }
+ return Addr;
}
template <typename SegmentType>
-static void
-constructSegment(SegmentType &Seg, llvm::MachO::LoadCommandType CmdType,
- StringRef SegName, uint64_t SegVMAddr, uint64_t SegVMSize) {
+static void
+constructSegment(SegmentType &Seg, llvm::MachO::LoadCommandType CmdType,
+ StringRef SegName, uint64_t SegVMAddr, uint64_t SegVMSize) {
assert(SegName.size() <= sizeof(Seg.segname) && "too long segment name");
memset(&Seg, 0, sizeof(SegmentType));
Seg.cmd = CmdType;
strncpy(Seg.segname, SegName.data(), SegName.size());
- Seg.maxprot |=
- (MachO::VM_PROT_READ | MachO::VM_PROT_WRITE | MachO::VM_PROT_EXECUTE);
- Seg.initprot |=
- (MachO::VM_PROT_READ | MachO::VM_PROT_WRITE | MachO::VM_PROT_EXECUTE);
- Seg.vmaddr = SegVMAddr;
- Seg.vmsize = SegVMSize;
+ Seg.maxprot |=
+ (MachO::VM_PROT_READ | MachO::VM_PROT_WRITE | MachO::VM_PROT_EXECUTE);
+ Seg.initprot |=
+ (MachO::VM_PROT_READ | MachO::VM_PROT_WRITE | MachO::VM_PROT_EXECUTE);
+ Seg.vmaddr = SegVMAddr;
+ Seg.vmsize = SegVMSize;
}
-LoadCommand &Object::addSegment(StringRef SegName, uint64_t SegVMSize) {
+LoadCommand &Object::addSegment(StringRef SegName, uint64_t SegVMSize) {
LoadCommand LC;
- const uint64_t SegVMAddr = nextAvailableSegmentAddress();
+ const uint64_t SegVMAddr = nextAvailableSegmentAddress();
if (is64Bit())
constructSegment(LC.MachOLoadCommand.segment_command_64_data,
- MachO::LC_SEGMENT_64, SegName, SegVMAddr, SegVMSize);
+ MachO::LC_SEGMENT_64, SegName, SegVMAddr, SegVMSize);
else
constructSegment(LC.MachOLoadCommand.segment_command_data,
- MachO::LC_SEGMENT, SegName, SegVMAddr, SegVMSize);
+ MachO::LC_SEGMENT, SegName, SegVMAddr, SegVMSize);
LoadCommands.push_back(std::move(LC));
return LoadCommands.back();
@@ -179,18 +179,18 @@ Optional<StringRef> LoadCommand::getSegmentName() const {
}
}
-Optional<uint64_t> LoadCommand::getSegmentVMAddr() const {
- const MachO::macho_load_command &MLC = MachOLoadCommand;
- switch (MLC.load_command_data.cmd) {
- case MachO::LC_SEGMENT:
- return MLC.segment_command_data.vmaddr;
- case MachO::LC_SEGMENT_64:
- return MLC.segment_command_64_data.vmaddr;
- default:
- return None;
- }
-}
-
+Optional<uint64_t> LoadCommand::getSegmentVMAddr() const {
+ const MachO::macho_load_command &MLC = MachOLoadCommand;
+ switch (MLC.load_command_data.cmd) {
+ case MachO::LC_SEGMENT:
+ return MLC.segment_command_data.vmaddr;
+ case MachO::LC_SEGMENT_64:
+ return MLC.segment_command_64_data.vmaddr;
+ default:
+ return None;
+ }
+}
+
} // end namespace macho
} // end namespace objcopy
} // end namespace llvm
diff --git a/contrib/libs/llvm12/tools/llvm-objcopy/MachO/Object.h b/contrib/libs/llvm12/tools/llvm-objcopy/MachO/Object.h
index 0bb4b344b2..111023017d 100644
--- a/contrib/libs/llvm12/tools/llvm-objcopy/MachO/Object.h
+++ b/contrib/libs/llvm12/tools/llvm-objcopy/MachO/Object.h
@@ -44,8 +44,8 @@ struct Section {
std::string CanonicalName;
uint64_t Addr = 0;
uint64_t Size = 0;
- // Offset in the input file.
- Optional<uint32_t> OriginalOffset;
+ // Offset in the input file.
+ Optional<uint32_t> OriginalOffset;
uint32_t Offset = 0;
uint32_t Align = 0;
uint32_t RelOff = 0;
@@ -75,10 +75,10 @@ struct Section {
getType() == MachO::S_GB_ZEROFILL ||
getType() == MachO::S_THREAD_LOCAL_ZEROFILL);
}
-
- bool hasValidOffset() const {
- return !(isVirtualSection() || (OriginalOffset && *OriginalOffset == 0));
- }
+
+ bool hasValidOffset() const {
+ return !(isVirtualSection() || (OriginalOffset && *OriginalOffset == 0));
+ }
};
struct LoadCommand {
@@ -100,9 +100,9 @@ struct LoadCommand {
// Returns the segment name if the load command is a segment command.
Optional<StringRef> getSegmentName() const;
-
- // Returns the segment vm address if the load command is a segment command.
- Optional<uint64_t> getSegmentVMAddr() const;
+
+ // Returns the segment vm address if the load command is a segment command.
+ Optional<uint64_t> getSegmentVMAddr() const;
};
// A symbol information. Fields which starts with "n_" are same as them in the
@@ -343,14 +343,14 @@ struct Object {
/// Creates a new segment load command in the object and returns a reference
/// to the newly created load command. The caller should verify that SegName
/// is not too long (SegName.size() should be less than or equal to 16).
- LoadCommand &addSegment(StringRef SegName, uint64_t SegVMSize);
+ LoadCommand &addSegment(StringRef SegName, uint64_t SegVMSize);
bool is64Bit() const {
return Header.Magic == MachO::MH_MAGIC_64 ||
Header.Magic == MachO::MH_CIGAM_64;
}
-
- uint64_t nextAvailableSegmentAddress() const;
+
+ uint64_t nextAvailableSegmentAddress() const;
};
} // end namespace macho
diff --git a/contrib/libs/llvm12/tools/llvm-objcopy/llvm-objcopy.cpp b/contrib/libs/llvm12/tools/llvm-objcopy/llvm-objcopy.cpp
index 7fd2acd11e..5d1366cad7 100644
--- a/contrib/libs/llvm12/tools/llvm-objcopy/llvm-objcopy.cpp
+++ b/contrib/libs/llvm12/tools/llvm-objcopy/llvm-objcopy.cpp
@@ -25,7 +25,7 @@
#include "llvm/Object/ELFTypes.h"
#include "llvm/Object/Error.h"
#include "llvm/Object/MachO.h"
-#include "llvm/Object/MachOUniversal.h"
+#include "llvm/Object/MachOUniversal.h"
#include "llvm/Object/Wasm.h"
#include "llvm/Option/Arg.h"
#include "llvm/Option/ArgList.h"
@@ -57,34 +57,34 @@ namespace objcopy {
// The name this program was invoked as.
StringRef ToolName;
-ErrorSuccess reportWarning(Error E) {
+ErrorSuccess reportWarning(Error E) {
assert(E);
- WithColor::warning(errs(), ToolName) << toString(std::move(E)) << '\n';
- return Error::success();
+ WithColor::warning(errs(), ToolName) << toString(std::move(E)) << '\n';
+ return Error::success();
}
-static Expected<DriverConfig> getDriverConfig(ArrayRef<const char *> Args) {
- StringRef Stem = sys::path::stem(ToolName);
- auto Is = [=](StringRef Tool) {
- // We need to recognize the following filenames:
- //
- // llvm-objcopy -> objcopy
- // strip-10.exe -> strip
- // powerpc64-unknown-freebsd13-objcopy -> objcopy
- // llvm-install-name-tool -> install-name-tool
- auto I = Stem.rfind_lower(Tool);
- return I != StringRef::npos &&
- (I + Tool.size() == Stem.size() || !isAlnum(Stem[I + Tool.size()]));
- };
-
- if (Is("bitcode-strip") || Is("bitcode_strip"))
- return parseBitcodeStripOptions(Args);
- else if (Is("strip"))
- return parseStripOptions(Args, reportWarning);
- else if (Is("install-name-tool") || Is("install_name_tool"))
- return parseInstallNameToolOptions(Args);
- else
- return parseObjcopyOptions(Args, reportWarning);
+static Expected<DriverConfig> getDriverConfig(ArrayRef<const char *> Args) {
+ StringRef Stem = sys::path::stem(ToolName);
+ auto Is = [=](StringRef Tool) {
+ // We need to recognize the following filenames:
+ //
+ // llvm-objcopy -> objcopy
+ // strip-10.exe -> strip
+ // powerpc64-unknown-freebsd13-objcopy -> objcopy
+ // llvm-install-name-tool -> install-name-tool
+ auto I = Stem.rfind_lower(Tool);
+ return I != StringRef::npos &&
+ (I + Tool.size() == Stem.size() || !isAlnum(Stem[I + Tool.size()]));
+ };
+
+ if (Is("bitcode-strip") || Is("bitcode_strip"))
+ return parseBitcodeStripOptions(Args);
+ else if (Is("strip"))
+ return parseStripOptions(Args, reportWarning);
+ else if (Is("install-name-tool") || Is("install_name_tool"))
+ return parseInstallNameToolOptions(Args);
+ else
+ return parseObjcopyOptions(Args, reportWarning);
}
} // end namespace objcopy
@@ -169,10 +169,10 @@ static Error executeObjcopyOnBinary(CopyConfig &Config, object::Binary &In,
return coff::executeObjcopyOnBinary(Config, *COFFBinary, Out);
else if (auto *MachOBinary = dyn_cast<object::MachOObjectFile>(&In))
return macho::executeObjcopyOnBinary(Config, *MachOBinary, Out);
- else if (auto *MachOUniversalBinary =
- dyn_cast<object::MachOUniversalBinary>(&In))
- return macho::executeObjcopyOnMachOUniversalBinary(
- Config, *MachOUniversalBinary, Out);
+ else if (auto *MachOUniversalBinary =
+ dyn_cast<object::MachOUniversalBinary>(&In))
+ return macho::executeObjcopyOnMachOUniversalBinary(
+ Config, *MachOUniversalBinary, Out);
else if (auto *WasmBinary = dyn_cast<object::WasmObjectFile>(&In))
return objcopy::wasm::executeObjcopyOnBinary(Config, *WasmBinary, Out);
else
@@ -180,11 +180,11 @@ static Error executeObjcopyOnBinary(CopyConfig &Config, object::Binary &In,
"unsupported object file format");
}
-namespace llvm {
-namespace objcopy {
-
-Expected<std::vector<NewArchiveMember>>
-createNewArchiveMembers(CopyConfig &Config, const Archive &Ar) {
+namespace llvm {
+namespace objcopy {
+
+Expected<std::vector<NewArchiveMember>>
+createNewArchiveMembers(CopyConfig &Config, const Archive &Ar) {
std::vector<NewArchiveMember> NewArchiveMembers;
Error Err = Error::success();
for (const Archive::Child &Child : Ar.children(Err)) {
@@ -199,7 +199,7 @@ createNewArchiveMembers(CopyConfig &Config, const Archive &Ar) {
MemBuffer MB(ChildNameOrErr.get());
if (Error E = executeObjcopyOnBinary(Config, *ChildOrErr->get(), MB))
- return std::move(E);
+ return std::move(E);
Expected<NewArchiveMember> Member =
NewArchiveMember::getOldMember(Child, Config.DeterministicArchives);
@@ -211,19 +211,19 @@ createNewArchiveMembers(CopyConfig &Config, const Archive &Ar) {
}
if (Err)
return createFileError(Config.InputFilename, std::move(Err));
- return std::move(NewArchiveMembers);
-}
-
-} // end namespace objcopy
-} // end namespace llvm
-
-static Error executeObjcopyOnArchive(CopyConfig &Config,
- const object::Archive &Ar) {
- Expected<std::vector<NewArchiveMember>> NewArchiveMembersOrErr =
- createNewArchiveMembers(Config, Ar);
- if (!NewArchiveMembersOrErr)
- return NewArchiveMembersOrErr.takeError();
- return deepWriteArchive(Config.OutputFilename, *NewArchiveMembersOrErr,
+ return std::move(NewArchiveMembers);
+}
+
+} // end namespace objcopy
+} // end namespace llvm
+
+static Error executeObjcopyOnArchive(CopyConfig &Config,
+ const object::Archive &Ar) {
+ Expected<std::vector<NewArchiveMember>> NewArchiveMembersOrErr =
+ createNewArchiveMembers(Config, Ar);
+ if (!NewArchiveMembersOrErr)
+ return NewArchiveMembersOrErr.takeError();
+ return deepWriteArchive(Config.OutputFilename, *NewArchiveMembersOrErr,
Ar.hasSymbolTable(), Ar.kind(),
Config.DeterministicArchives, Ar.isThin());
}
@@ -353,8 +353,8 @@ int main(int argc, char **argv) {
NewArgv);
auto Args = makeArrayRef(NewArgv).drop_front();
- Expected<DriverConfig> DriverConfig = getDriverConfig(Args);
-
+ Expected<DriverConfig> DriverConfig = getDriverConfig(Args);
+
if (!DriverConfig) {
logAllUnhandledErrors(DriverConfig.takeError(),
WithColor::error(errs(), ToolName));
diff --git a/contrib/libs/llvm12/tools/llvm-objcopy/llvm-objcopy.h b/contrib/libs/llvm12/tools/llvm-objcopy/llvm-objcopy.h
index 97a166769f..fa9fa4c1a5 100644
--- a/contrib/libs/llvm12/tools/llvm-objcopy/llvm-objcopy.h
+++ b/contrib/libs/llvm12/tools/llvm-objcopy/llvm-objcopy.h
@@ -13,19 +13,19 @@
namespace llvm {
-struct NewArchiveMember;
-
-namespace object {
-
-class Archive;
-
-} // end namespace object
-
-namespace objcopy {
-struct CopyConfig;
-Expected<std::vector<NewArchiveMember>>
-createNewArchiveMembers(CopyConfig &Config, const object::Archive &Ar);
-
+struct NewArchiveMember;
+
+namespace object {
+
+class Archive;
+
+} // end namespace object
+
+namespace objcopy {
+struct CopyConfig;
+Expected<std::vector<NewArchiveMember>>
+createNewArchiveMembers(CopyConfig &Config, const object::Archive &Ar);
+
} // end namespace objcopy
} // end namespace llvm
diff --git a/contrib/libs/llvm12/tools/llvm-objcopy/wasm/Object.cpp b/contrib/libs/llvm12/tools/llvm-objcopy/wasm/Object.cpp
index e7a2956fed..3e39e16f15 100644
--- a/contrib/libs/llvm12/tools/llvm-objcopy/wasm/Object.cpp
+++ b/contrib/libs/llvm12/tools/llvm-objcopy/wasm/Object.cpp
@@ -26,7 +26,7 @@ void Object::addSectionWithOwnedContents(
void Object::removeSections(function_ref<bool(const Section &)> ToRemove) {
// TODO: remove reloc sections for the removed section, handle symbols, etc.
- llvm::erase_if(Sections, ToRemove);
+ llvm::erase_if(Sections, ToRemove);
}
} // end namespace wasm
diff --git a/contrib/libs/llvm12/tools/llvm-objcopy/ya.make b/contrib/libs/llvm12/tools/llvm-objcopy/ya.make
index 13845f4bfa..461adedfd6 100644
--- a/contrib/libs/llvm12/tools/llvm-objcopy/ya.make
+++ b/contrib/libs/llvm12/tools/llvm-objcopy/ya.make
@@ -12,25 +12,25 @@ LICENSE(Apache-2.0 WITH LLVM-exception)
LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
PEERDIR(
- contrib/libs/llvm12
- contrib/libs/llvm12/include
- contrib/libs/llvm12/lib/BinaryFormat
- contrib/libs/llvm12/lib/Bitcode/Reader
- contrib/libs/llvm12/lib/Bitstream/Reader
- contrib/libs/llvm12/lib/Demangle
- contrib/libs/llvm12/lib/IR
- contrib/libs/llvm12/lib/MC
- contrib/libs/llvm12/lib/MC/MCParser
- contrib/libs/llvm12/lib/Object
- contrib/libs/llvm12/lib/Option
- contrib/libs/llvm12/lib/Remarks
- contrib/libs/llvm12/lib/Support
- contrib/libs/llvm12/lib/TextAPI/MachO
+ contrib/libs/llvm12
+ contrib/libs/llvm12/include
+ contrib/libs/llvm12/lib/BinaryFormat
+ contrib/libs/llvm12/lib/Bitcode/Reader
+ contrib/libs/llvm12/lib/Bitstream/Reader
+ contrib/libs/llvm12/lib/Demangle
+ contrib/libs/llvm12/lib/IR
+ contrib/libs/llvm12/lib/MC
+ contrib/libs/llvm12/lib/MC/MCParser
+ contrib/libs/llvm12/lib/Object
+ contrib/libs/llvm12/lib/Option
+ contrib/libs/llvm12/lib/Remarks
+ contrib/libs/llvm12/lib/Support
+ contrib/libs/llvm12/lib/TextAPI/MachO
)
ADDINCL(
- ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-objcopy
- contrib/libs/llvm12/tools/llvm-objcopy
+ ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-objcopy
+ contrib/libs/llvm12/tools/llvm-objcopy
)
NO_COMPILER_WARNINGS()
diff --git a/contrib/libs/llvm12/tools/llvm-rc/Opts.td b/contrib/libs/llvm12/tools/llvm-rc/Opts.td
index 613f0a0db3..065fb3f7cd 100644
--- a/contrib/libs/llvm12/tools/llvm-rc/Opts.td
+++ b/contrib/libs/llvm12/tools/llvm-rc/Opts.td
@@ -4,55 +4,55 @@ include "llvm/Option/OptParser.td"
// These options seem to be important for the tool
// and should be implemented.
-def fileout : JoinedOrSeparate<[ "/", "-" ], "FO">,
+def fileout : JoinedOrSeparate<[ "/", "-" ], "FO">,
HelpText<"Change the output file location.">;
-def define : Separate<[ "/", "-" ], "D">,
+def define : Separate<[ "/", "-" ], "D">,
HelpText<"Define a symbol for the C preprocessor.">;
-def undef : Separate<[ "/", "-" ], "U">,
+def undef : Separate<[ "/", "-" ], "U">,
HelpText<"Undefine a symbol for the C preprocessor.">;
-def lang_id : JoinedOrSeparate<[ "/", "-" ], "L">,
+def lang_id : JoinedOrSeparate<[ "/", "-" ], "L">,
HelpText<"Set the default language identifier.">;
-def lang_name : Separate<[ "/", "-" ], "LN">,
+def lang_name : Separate<[ "/", "-" ], "LN">,
HelpText<"Set the default language name.">;
-def includepath : Separate<[ "/", "-" ], "I">, HelpText<"Add an include path.">;
-def noinclude : Flag<[ "/", "-" ], "X">, HelpText<"Ignore 'include' variable.">;
+def includepath : Separate<[ "/", "-" ], "I">, HelpText<"Add an include path.">;
+def noinclude : Flag<[ "/", "-" ], "X">, HelpText<"Ignore 'include' variable.">;
-def add_null : Flag<[ "/", "-" ], "N">,
+def add_null : Flag<[ "/", "-" ], "N">,
HelpText<"Null-terminate all strings in the string table.">;
-def dupid_nowarn : Flag<[ "/", "-" ], "Y">,
+def dupid_nowarn : Flag<[ "/", "-" ], "Y">,
HelpText<"Suppress warnings on duplicate resource IDs.">;
-def verbose : Flag<[ "/", "-" ], "V">, HelpText<"Be verbose.">;
-def help : Flag<[ "/", "-" ], "?">, HelpText<"Display this help and exit.">;
-def h : Flag<[ "/", "-" ], "H">,
- Alias<help>,
+def verbose : Flag<[ "/", "-" ], "V">, HelpText<"Be verbose.">;
+def help : Flag<[ "/", "-" ], "?">, HelpText<"Display this help and exit.">;
+def h : Flag<[ "/", "-" ], "H">,
+ Alias<help>,
HelpText<"Display this help and exit.">;
-def dry_run : Flag<[ "/", "-" ], "dry-run">,
+def dry_run : Flag<[ "/", "-" ], "dry-run">,
HelpText<"Don't compile the input; only try to parse it.">;
-def codepage : JoinedOrSeparate<[ "/", "-" ], "C">,
+def codepage : JoinedOrSeparate<[ "/", "-" ], "C">,
HelpText<"Set the codepage used for input strings.">;
// Unused switches (at least for now). These will stay unimplemented
// in an early stage of development and can be ignored. However, we need to
// parse them in order to preserve the compatibility with the original tool.
-def nologo : Flag<[ "/", "-" ], "NOLOGO">;
-def r : Flag<[ "/", "-" ], "R">;
-def sl : Flag<[ "/", "-" ], "SL">;
+def nologo : Flag<[ "/", "-" ], "NOLOGO">;
+def r : Flag<[ "/", "-" ], "R">;
+def sl : Flag<[ "/", "-" ], "SL">;
// (Codepages support.)
-def w : Flag<[ "/", "-" ], "W">;
+def w : Flag<[ "/", "-" ], "W">;
// (Support of MUI and similar.)
-def fm : Separate<[ "/", "-" ], "FM">;
-def q : Separate<[ "/", "-" ], "Q">;
-def g : Flag<[ "/", "-" ], "G">;
-def gn : Flag<[ "/", "-" ], "GN">;
-def g1 : Flag<[ "/", "-" ], "G1">;
-def g2 : Flag<[ "/", "-" ], "G2">;
+def fm : Separate<[ "/", "-" ], "FM">;
+def q : Separate<[ "/", "-" ], "Q">;
+def g : Flag<[ "/", "-" ], "G">;
+def gn : Flag<[ "/", "-" ], "GN">;
+def g1 : Flag<[ "/", "-" ], "G1">;
+def g2 : Flag<[ "/", "-" ], "G2">;
diff --git a/contrib/libs/llvm12/tools/llvm-rc/ResourceFileWriter.cpp b/contrib/libs/llvm12/tools/llvm-rc/ResourceFileWriter.cpp
index 553bb754ae..8b2de62cb1 100644
--- a/contrib/libs/llvm12/tools/llvm-rc/ResourceFileWriter.cpp
+++ b/contrib/libs/llvm12/tools/llvm-rc/ResourceFileWriter.cpp
@@ -138,8 +138,8 @@ enum class NullHandlingMethod {
};
// Parses an identifier or string and returns a processed version of it:
-// * Strip the string boundary quotes.
-// * Convert the input code page characters to UTF16.
+// * Strip the string boundary quotes.
+// * Convert the input code page characters to UTF16.
// * Squash "" to a single ".
// * Replace the escape sequences with their processed version.
// For identifiers, this is no-op.
@@ -1514,16 +1514,16 @@ ResourceFileWriter::loadFile(StringRef File) const {
SmallString<128> Cwd;
std::unique_ptr<MemoryBuffer> Result;
- // 0. The file path is absolute or has a root directory, so we shouldn't
- // try to append it on top of other base directories. (An absolute path
- // must have a root directory, but e.g. the path "\dir\file" on windows
- // isn't considered absolute, but it does have a root directory. As long as
- // sys::path::append doesn't handle appending an absolute path or a path
- // starting with a root directory on top of a base, we must handle this
- // case separately at the top. C++17's path::append handles that case
- // properly though, so if using that to append paths below, this early
- // exception case could be removed.)
- if (sys::path::has_root_directory(File))
+ // 0. The file path is absolute or has a root directory, so we shouldn't
+ // try to append it on top of other base directories. (An absolute path
+ // must have a root directory, but e.g. the path "\dir\file" on windows
+ // isn't considered absolute, but it does have a root directory. As long as
+ // sys::path::append doesn't handle appending an absolute path or a path
+ // starting with a root directory on top of a base, we must handle this
+ // case separately at the top. C++17's path::append handles that case
+ // properly though, so if using that to append paths below, this early
+ // exception case could be removed.)
+ if (sys::path::has_root_directory(File))
return errorOrToExpected(MemoryBuffer::getFile(File, -1, false));
// 1. The current working directory.
diff --git a/contrib/libs/llvm12/tools/llvm-rc/ResourceScriptParser.cpp b/contrib/libs/llvm12/tools/llvm-rc/ResourceScriptParser.cpp
index 5141ac0c38..d39665996d 100644
--- a/contrib/libs/llvm12/tools/llvm-rc/ResourceScriptParser.cpp
+++ b/contrib/libs/llvm12/tools/llvm-rc/ResourceScriptParser.cpp
@@ -777,10 +777,10 @@ RCParser::parseVersionInfoFixed() {
// VERSION variations take multiple integers.
size_t NumInts = RetType::isVersionType(FixedType) ? 4 : 1;
- ASSIGN_OR_RETURN(ArgsResult, readIntsWithCommas(1, NumInts));
+ ASSIGN_OR_RETURN(ArgsResult, readIntsWithCommas(1, NumInts));
SmallVector<uint32_t, 4> ArgInts(ArgsResult->begin(), ArgsResult->end());
- while (ArgInts.size() < NumInts)
- ArgInts.push_back(0);
+ while (ArgInts.size() < NumInts)
+ ArgInts.push_back(0);
Result.setValue(FixedType, ArgInts);
}
diff --git a/contrib/libs/llvm12/tools/llvm-rc/ResourceScriptStmt.h b/contrib/libs/llvm12/tools/llvm-rc/ResourceScriptStmt.h
index 27fbea3ae8..6102a1c51e 100644
--- a/contrib/libs/llvm12/tools/llvm-rc/ResourceScriptStmt.h
+++ b/contrib/libs/llvm12/tools/llvm-rc/ResourceScriptStmt.h
@@ -289,9 +289,9 @@ public:
: RCResource(Flags),
OptStatements(std::make_unique<OptionalStmtList>(std::move(Stmts))) {}
- Error applyStmts(Visitor *V) const override {
- return OptStatements->visit(V);
- }
+ Error applyStmts(Visitor *V) const override {
+ return OptStatements->visit(V);
+ }
};
// LANGUAGE statement. It can occur both as a top-level statement (in such
diff --git a/contrib/libs/llvm12/tools/llvm-rc/llvm-rc.cpp b/contrib/libs/llvm12/tools/llvm-rc/llvm-rc.cpp
index e9027a21d4..415701ddac 100644
--- a/contrib/libs/llvm12/tools/llvm-rc/llvm-rc.cpp
+++ b/contrib/libs/llvm12/tools/llvm-rc/llvm-rc.cpp
@@ -92,12 +92,12 @@ int main(int Argc, const char **Argv) {
opt::InputArgList InputArgs = T.ParseArgs(ArgsArr, MAI, MAC);
// The tool prints nothing when invoked with no command-line arguments.
- if (InputArgs.hasArg(OPT_help)) {
+ if (InputArgs.hasArg(OPT_help)) {
T.PrintHelp(outs(), "rc [options] file...", "Resource Converter", false);
return 0;
}
- const bool BeVerbose = InputArgs.hasArg(OPT_verbose);
+ const bool BeVerbose = InputArgs.hasArg(OPT_verbose);
std::vector<std::string> InArgsInfo = InputArgs.getAllArgValues(OPT_INPUT);
if (DashDash != Argv + Argc)
@@ -141,14 +141,14 @@ int main(int Argc, const char **Argv) {
SmallString<128> InputFile(InArgsInfo[0]);
llvm::sys::fs::make_absolute(InputFile);
Params.InputFilePath = InputFile;
- Params.Include = InputArgs.getAllArgValues(OPT_includepath);
- Params.NoInclude = InputArgs.getAllArgValues(OPT_noinclude);
+ Params.Include = InputArgs.getAllArgValues(OPT_includepath);
+ Params.NoInclude = InputArgs.getAllArgValues(OPT_noinclude);
- if (InputArgs.hasArg(OPT_codepage)) {
- if (InputArgs.getLastArgValue(OPT_codepage)
+ if (InputArgs.hasArg(OPT_codepage)) {
+ if (InputArgs.getLastArgValue(OPT_codepage)
.getAsInteger(10, Params.CodePage))
fatalError("Invalid code page: " +
- InputArgs.getLastArgValue(OPT_codepage));
+ InputArgs.getLastArgValue(OPT_codepage));
switch (Params.CodePage) {
case CpAcp:
case CpWin1252:
@@ -161,10 +161,10 @@ int main(int Argc, const char **Argv) {
}
std::unique_ptr<ResourceFileWriter> Visitor;
- bool IsDryRun = InputArgs.hasArg(OPT_dry_run);
+ bool IsDryRun = InputArgs.hasArg(OPT_dry_run);
if (!IsDryRun) {
- auto OutArgsInfo = InputArgs.getAllArgValues(OPT_fileout);
+ auto OutArgsInfo = InputArgs.getAllArgValues(OPT_fileout);
if (OutArgsInfo.empty()) {
SmallString<128> OutputFile = InputFile;
llvm::sys::path::replace_extension(OutputFile, "res");
@@ -182,17 +182,17 @@ int main(int Argc, const char **Argv) {
fatalError("Error opening output file '" + OutArgsInfo[0] +
"': " + EC.message());
Visitor = std::make_unique<ResourceFileWriter>(Params, std::move(FOut));
- Visitor->AppendNull = InputArgs.hasArg(OPT_add_null);
+ Visitor->AppendNull = InputArgs.hasArg(OPT_add_null);
ExitOnErr(NullResource().visit(Visitor.get()));
// Set the default language; choose en-US arbitrarily.
unsigned PrimaryLangId = 0x09, SubLangId = 0x01;
- if (InputArgs.hasArg(OPT_lang_id)) {
+ if (InputArgs.hasArg(OPT_lang_id)) {
unsigned LangId;
- if (InputArgs.getLastArgValue(OPT_lang_id).getAsInteger(16, LangId))
+ if (InputArgs.getLastArgValue(OPT_lang_id).getAsInteger(16, LangId))
fatalError("Invalid language id: " +
- InputArgs.getLastArgValue(OPT_lang_id));
+ InputArgs.getLastArgValue(OPT_lang_id));
PrimaryLangId = LangId & 0x3ff;
SubLangId = LangId >> 10;
}
diff --git a/contrib/libs/llvm12/tools/llvm-rc/ya.make b/contrib/libs/llvm12/tools/llvm-rc/ya.make
index e69f41f542..b54fb969ea 100644
--- a/contrib/libs/llvm12/tools/llvm-rc/ya.make
+++ b/contrib/libs/llvm12/tools/llvm-rc/ya.make
@@ -12,16 +12,16 @@ LICENSE(Apache-2.0 WITH LLVM-exception)
LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
PEERDIR(
- contrib/libs/llvm12
- contrib/libs/llvm12/include
- contrib/libs/llvm12/lib/Demangle
- contrib/libs/llvm12/lib/Option
- contrib/libs/llvm12/lib/Support
+ contrib/libs/llvm12
+ contrib/libs/llvm12/include
+ contrib/libs/llvm12/lib/Demangle
+ contrib/libs/llvm12/lib/Option
+ contrib/libs/llvm12/lib/Support
)
ADDINCL(
- ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-rc
- contrib/libs/llvm12/tools/llvm-rc
+ ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-rc
+ contrib/libs/llvm12/tools/llvm-rc
)
NO_COMPILER_WARNINGS()
diff --git a/contrib/libs/llvm12/tools/llvm-symbolizer/Opts.td b/contrib/libs/llvm12/tools/llvm-symbolizer/Opts.td
index ac23639f13..aff1181799 100644
--- a/contrib/libs/llvm12/tools/llvm-symbolizer/Opts.td
+++ b/contrib/libs/llvm12/tools/llvm-symbolizer/Opts.td
@@ -1,71 +1,71 @@
-include "llvm/Option/OptParser.td"
-
-multiclass B<string name, string help1, string help2> {
- def NAME: Flag<["--", "-"], name>, HelpText<help1>;
- def no_ # NAME: Flag<["--", "-"], "no-" # name>, HelpText<help2>;
-}
-
-multiclass Eq<string name, string help> {
- def NAME #_EQ : Joined<["--", "-"], name #"=">,
- HelpText<help>;
- def : Separate<["--", "-"], name>, Alias<!cast<Joined>(NAME #_EQ)>;
-}
-
-class F<string name, string help>: Flag<["--", "-"], name>, HelpText<help>;
-
-def addresses : F<"addresses", "Show address before line information">;
-defm adjust_vma
- : Eq<"adjust-vma", "Add specified offset to object file addresses">,
- MetaVarName<"<offset>">;
-def basenames : Flag<["--"], "basenames">, HelpText<"Strip directory names from paths">;
-defm debug_file_directory : Eq<"debug-file-directory", "Path to directory where to look for debug files">, MetaVarName<"<dir>">;
-defm default_arch : Eq<"default-arch", "Default architecture (for multi-arch objects)">;
-defm demangle : B<"demangle", "Demangle function names", "Don't demangle function names">;
-def functions : F<"functions", "Print function name for a given address">;
-def functions_EQ : Joined<["--"], "functions=">, HelpText<"Print function name for a given address">, Values<"none,short,linkage">;
-def help : F<"help", "Display this help">;
-defm dwp : Eq<"dwp", "Path to DWP file to be use for any split CUs">, MetaVarName<"<file>">;
-defm dsym_hint : Eq<"dsym-hint", "Path to .dSYM bundles to search for debug info for the object files">, MetaVarName<"<dir>">;
-defm fallback_debug_path : Eq<"fallback-debug-path", "Fallback path for debug binaries">, MetaVarName<"<dir>">;
-defm inlines : B<"inlines", "Print all inlined frames for a given address",
- "Do not print inlined frames">;
-defm obj
- : Eq<"obj", "Path to object file to be symbolized (if not provided, "
- "object file should be specified for each input line)">, MetaVarName<"<file>">;
-defm output_style
- : Eq<"output-style", "Specify print style. Supported styles: LLVM, GNU">,
- MetaVarName<"style">,
- Values<"LLVM,GNU">;
-def pretty_print : F<"pretty-print", "Make the output more human friendly">;
-defm print_source_context_lines : Eq<"print-source-context-lines", "Print N lines of source file context">;
-def relative_address : F<"relative-address", "Interpret addresses as addresses relative to the image base">;
-def relativenames : F<"relativenames", "Strip the compilation directory from paths">;
-defm untag_addresses : B<"untag-addresses", "", "Remove memory tags from addresses before symbolization">;
-def use_dia: F<"dia", "Use the DIA library to access symbols (Windows only)">;
-def verbose : F<"verbose", "Print verbose line info">;
-def version : F<"version", "Display the version">;
-
-def : Flag<["-"], "a">, Alias<addresses>, HelpText<"Alias for --addresses">;
-def : F<"print-address", "Alias for --addresses">, Alias<addresses>;
-def : Flag<["-"], "C">, Alias<demangle>, HelpText<"Alias for --demangle">;
-def : Joined<["--"], "exe=">, Alias<obj_EQ>, HelpText<"Alias for --obj">, MetaVarName<"<file>">;
-def : Separate<["--"], "exe">, Alias<obj_EQ>, HelpText<"Alias for --obj">, MetaVarName<"<file>">;
-def : JoinedOrSeparate<["-"], "e">, Alias<obj_EQ>, HelpText<"Alias for --obj">, MetaVarName<"<file>">;
-def : Joined<["-"], "e=">, Alias<obj_EQ>, HelpText<"Alias for --obj">, MetaVarName<"<file>">;
-def : Flag<["-"], "f">, Alias<functions>, HelpText<"Alias for --functions">;
-def : Joined<["-"], "f=">, Alias<functions_EQ>, HelpText<"Alias for --functions=">;
-def : Flag<["-"], "h">, Alias<help>;
-def : Flag<["-"], "i">, Alias<inlines>, HelpText<"Alias for --inlines">;
-def : F<"inlining", "Alias for --inlines">, Alias<inlines>;
-def : Flag<["-"], "p">, Alias<pretty_print>, HelpText<"Alias for --pretty-print">;
-def : Flag<["-"], "s">, Alias<basenames>, HelpText<"Alias for --basenames">;
-def : Flag<["-"], "v">, Alias<version>, HelpText<"Alias for --version">;
-
-// Compatibility aliases for old asan_symbolize.py and sanitizer binaries (before 2020-08).
-def : Flag<["--"], "inlining=true">, Alias<inlines>, HelpText<"Alias for --inlines">;
-def : Flag<["--"], "inlining=false">, Alias<no_inlines>, HelpText<"Alias for --no-inlines">;
-// Compatibility aliases for pprof's symbolizer.
-def : Flag<["-"], "demangle=true">, Alias<demangle>, HelpText<"Alias for --demangle">;
-def : Flag<["-"], "demangle=false">, Alias<no_demangle>, HelpText<"Alias for --no-demangle">;
-// Compatibility no-op options.
-def : Flag<["--"], "use-symbol-table=true">;
+include "llvm/Option/OptParser.td"
+
+multiclass B<string name, string help1, string help2> {
+ def NAME: Flag<["--", "-"], name>, HelpText<help1>;
+ def no_ # NAME: Flag<["--", "-"], "no-" # name>, HelpText<help2>;
+}
+
+multiclass Eq<string name, string help> {
+ def NAME #_EQ : Joined<["--", "-"], name #"=">,
+ HelpText<help>;
+ def : Separate<["--", "-"], name>, Alias<!cast<Joined>(NAME #_EQ)>;
+}
+
+class F<string name, string help>: Flag<["--", "-"], name>, HelpText<help>;
+
+def addresses : F<"addresses", "Show address before line information">;
+defm adjust_vma
+ : Eq<"adjust-vma", "Add specified offset to object file addresses">,
+ MetaVarName<"<offset>">;
+def basenames : Flag<["--"], "basenames">, HelpText<"Strip directory names from paths">;
+defm debug_file_directory : Eq<"debug-file-directory", "Path to directory where to look for debug files">, MetaVarName<"<dir>">;
+defm default_arch : Eq<"default-arch", "Default architecture (for multi-arch objects)">;
+defm demangle : B<"demangle", "Demangle function names", "Don't demangle function names">;
+def functions : F<"functions", "Print function name for a given address">;
+def functions_EQ : Joined<["--"], "functions=">, HelpText<"Print function name for a given address">, Values<"none,short,linkage">;
+def help : F<"help", "Display this help">;
+defm dwp : Eq<"dwp", "Path to DWP file to be use for any split CUs">, MetaVarName<"<file>">;
+defm dsym_hint : Eq<"dsym-hint", "Path to .dSYM bundles to search for debug info for the object files">, MetaVarName<"<dir>">;
+defm fallback_debug_path : Eq<"fallback-debug-path", "Fallback path for debug binaries">, MetaVarName<"<dir>">;
+defm inlines : B<"inlines", "Print all inlined frames for a given address",
+ "Do not print inlined frames">;
+defm obj
+ : Eq<"obj", "Path to object file to be symbolized (if not provided, "
+ "object file should be specified for each input line)">, MetaVarName<"<file>">;
+defm output_style
+ : Eq<"output-style", "Specify print style. Supported styles: LLVM, GNU">,
+ MetaVarName<"style">,
+ Values<"LLVM,GNU">;
+def pretty_print : F<"pretty-print", "Make the output more human friendly">;
+defm print_source_context_lines : Eq<"print-source-context-lines", "Print N lines of source file context">;
+def relative_address : F<"relative-address", "Interpret addresses as addresses relative to the image base">;
+def relativenames : F<"relativenames", "Strip the compilation directory from paths">;
+defm untag_addresses : B<"untag-addresses", "", "Remove memory tags from addresses before symbolization">;
+def use_dia: F<"dia", "Use the DIA library to access symbols (Windows only)">;
+def verbose : F<"verbose", "Print verbose line info">;
+def version : F<"version", "Display the version">;
+
+def : Flag<["-"], "a">, Alias<addresses>, HelpText<"Alias for --addresses">;
+def : F<"print-address", "Alias for --addresses">, Alias<addresses>;
+def : Flag<["-"], "C">, Alias<demangle>, HelpText<"Alias for --demangle">;
+def : Joined<["--"], "exe=">, Alias<obj_EQ>, HelpText<"Alias for --obj">, MetaVarName<"<file>">;
+def : Separate<["--"], "exe">, Alias<obj_EQ>, HelpText<"Alias for --obj">, MetaVarName<"<file>">;
+def : JoinedOrSeparate<["-"], "e">, Alias<obj_EQ>, HelpText<"Alias for --obj">, MetaVarName<"<file>">;
+def : Joined<["-"], "e=">, Alias<obj_EQ>, HelpText<"Alias for --obj">, MetaVarName<"<file>">;
+def : Flag<["-"], "f">, Alias<functions>, HelpText<"Alias for --functions">;
+def : Joined<["-"], "f=">, Alias<functions_EQ>, HelpText<"Alias for --functions=">;
+def : Flag<["-"], "h">, Alias<help>;
+def : Flag<["-"], "i">, Alias<inlines>, HelpText<"Alias for --inlines">;
+def : F<"inlining", "Alias for --inlines">, Alias<inlines>;
+def : Flag<["-"], "p">, Alias<pretty_print>, HelpText<"Alias for --pretty-print">;
+def : Flag<["-"], "s">, Alias<basenames>, HelpText<"Alias for --basenames">;
+def : Flag<["-"], "v">, Alias<version>, HelpText<"Alias for --version">;
+
+// Compatibility aliases for old asan_symbolize.py and sanitizer binaries (before 2020-08).
+def : Flag<["--"], "inlining=true">, Alias<inlines>, HelpText<"Alias for --inlines">;
+def : Flag<["--"], "inlining=false">, Alias<no_inlines>, HelpText<"Alias for --no-inlines">;
+// Compatibility aliases for pprof's symbolizer.
+def : Flag<["-"], "demangle=true">, Alias<demangle>, HelpText<"Alias for --demangle">;
+def : Flag<["-"], "demangle=false">, Alias<no_demangle>, HelpText<"Alias for --no-demangle">;
+// Compatibility no-op options.
+def : Flag<["--"], "use-symbol-table=true">;
diff --git a/contrib/libs/llvm12/tools/llvm-symbolizer/llvm-symbolizer.cpp b/contrib/libs/llvm12/tools/llvm-symbolizer/llvm-symbolizer.cpp
index 8734c2d740..f85ed6dc7e 100644
--- a/contrib/libs/llvm12/tools/llvm-symbolizer/llvm-symbolizer.cpp
+++ b/contrib/libs/llvm12/tools/llvm-symbolizer/llvm-symbolizer.cpp
@@ -14,21 +14,21 @@
//
//===----------------------------------------------------------------------===//
-#include "Opts.inc"
+#include "Opts.inc"
#include "llvm/ADT/StringRef.h"
-#include "llvm/Config/config.h"
+#include "llvm/Config/config.h"
#include "llvm/DebugInfo/Symbolize/DIPrinter.h"
#include "llvm/DebugInfo/Symbolize/Symbolize.h"
-#include "llvm/Option/Arg.h"
-#include "llvm/Option/ArgList.h"
-#include "llvm/Option/Option.h"
+#include "llvm/Option/Arg.h"
+#include "llvm/Option/ArgList.h"
+#include "llvm/Option/Option.h"
#include "llvm/Support/COM.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/InitLLVM.h"
#include "llvm/Support/Path.h"
-#include "llvm/Support/StringSaver.h"
+#include "llvm/Support/StringSaver.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cstdio>
@@ -38,37 +38,37 @@
using namespace llvm;
using namespace symbolize;
-namespace {
-enum ID {
- OPT_INVALID = 0, // This is not an option ID.
-#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
- HELPTEXT, METAVAR, VALUES) \
- OPT_##ID,
-#include "Opts.inc"
-#undef OPTION
-};
+namespace {
+enum ID {
+ OPT_INVALID = 0, // This is not an option ID.
+#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
+ HELPTEXT, METAVAR, VALUES) \
+ OPT_##ID,
+#include "Opts.inc"
+#undef OPTION
+};
-#define PREFIX(NAME, VALUE) const char *const NAME[] = VALUE;
-#include "Opts.inc"
-#undef PREFIX
+#define PREFIX(NAME, VALUE) const char *const NAME[] = VALUE;
+#include "Opts.inc"
+#undef PREFIX
-static const opt::OptTable::Info InfoTable[] = {
-#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
- HELPTEXT, METAVAR, VALUES) \
- { \
- PREFIX, NAME, HELPTEXT, \
- METAVAR, OPT_##ID, opt::Option::KIND##Class, \
- PARAM, FLAGS, OPT_##GROUP, \
- OPT_##ALIAS, ALIASARGS, VALUES},
-#include "Opts.inc"
-#undef OPTION
-};
+static const opt::OptTable::Info InfoTable[] = {
+#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
+ HELPTEXT, METAVAR, VALUES) \
+ { \
+ PREFIX, NAME, HELPTEXT, \
+ METAVAR, OPT_##ID, opt::Option::KIND##Class, \
+ PARAM, FLAGS, OPT_##GROUP, \
+ OPT_##ALIAS, ALIASARGS, VALUES},
+#include "Opts.inc"
+#undef OPTION
+};
-class SymbolizerOptTable : public opt::OptTable {
-public:
- SymbolizerOptTable() : OptTable(InfoTable, true) {}
-};
-} // namespace
+class SymbolizerOptTable : public opt::OptTable {
+public:
+ SymbolizerOptTable() : OptTable(InfoTable, true) {}
+};
+} // namespace
static cl::list<std::string> ClInputAddresses(cl::Positional,
cl::desc("<input addresses>..."),
@@ -89,8 +89,8 @@ enum class Command {
Frame,
};
-static bool parseCommand(StringRef BinaryName, bool IsAddr2Line,
- StringRef InputString, Command &Cmd,
+static bool parseCommand(StringRef BinaryName, bool IsAddr2Line,
+ StringRef InputString, Command &Cmd,
std::string &ModuleName, uint64_t &ModuleOffset) {
const char kDelimiters[] = " \n\r";
ModuleName = "";
@@ -106,7 +106,7 @@ static bool parseCommand(StringRef BinaryName, bool IsAddr2Line,
}
const char *Pos = InputString.data();
// Skip delimiters and parse input filename (if needed).
- if (BinaryName.empty()) {
+ if (BinaryName.empty()) {
Pos += strspn(Pos, kDelimiters);
if (*Pos == '"' || *Pos == '\'') {
char Quote = *Pos;
@@ -122,7 +122,7 @@ static bool parseCommand(StringRef BinaryName, bool IsAddr2Line,
Pos += NameLength;
}
} else {
- ModuleName = BinaryName.str();
+ ModuleName = BinaryName.str();
}
// Skip delimiters and parse module offset.
Pos += strspn(Pos, kDelimiters);
@@ -135,26 +135,26 @@ static bool parseCommand(StringRef BinaryName, bool IsAddr2Line,
return !Offset.getAsInteger(IsAddr2Line ? 16 : 0, ModuleOffset);
}
-static void symbolizeInput(const opt::InputArgList &Args, uint64_t AdjustVMA,
- bool IsAddr2Line, DIPrinter::OutputStyle OutputStyle,
- StringRef InputString, LLVMSymbolizer &Symbolizer,
- DIPrinter &Printer) {
+static void symbolizeInput(const opt::InputArgList &Args, uint64_t AdjustVMA,
+ bool IsAddr2Line, DIPrinter::OutputStyle OutputStyle,
+ StringRef InputString, LLVMSymbolizer &Symbolizer,
+ DIPrinter &Printer) {
Command Cmd;
std::string ModuleName;
uint64_t Offset = 0;
- if (!parseCommand(Args.getLastArgValue(OPT_obj_EQ), IsAddr2Line,
- StringRef(InputString), Cmd, ModuleName, Offset)) {
+ if (!parseCommand(Args.getLastArgValue(OPT_obj_EQ), IsAddr2Line,
+ StringRef(InputString), Cmd, ModuleName, Offset)) {
outs() << InputString << "\n";
return;
}
- if (Args.hasArg(OPT_addresses)) {
+ if (Args.hasArg(OPT_addresses)) {
outs() << "0x";
outs().write_hex(Offset);
- StringRef Delimiter = Args.hasArg(OPT_pretty_print) ? ": " : "\n";
+ StringRef Delimiter = Args.hasArg(OPT_pretty_print) ? ": " : "\n";
outs() << Delimiter;
}
- Offset -= AdjustVMA;
+ Offset -= AdjustVMA;
if (Cmd == Command::Data) {
auto ResOrErr = Symbolizer.symbolizeData(
ModuleName, {Offset, object::SectionedAddress::UndefSection});
@@ -168,182 +168,182 @@ static void symbolizeInput(const opt::InputArgList &Args, uint64_t AdjustVMA,
if (ResOrErr->empty())
outs() << "??\n";
}
- } else if (Args.hasFlag(OPT_inlines, OPT_no_inlines, !IsAddr2Line)) {
+ } else if (Args.hasFlag(OPT_inlines, OPT_no_inlines, !IsAddr2Line)) {
auto ResOrErr = Symbolizer.symbolizeInlinedCode(
ModuleName, {Offset, object::SectionedAddress::UndefSection});
Printer << (error(ResOrErr) ? DIInliningInfo() : ResOrErr.get());
- } else if (OutputStyle == DIPrinter::OutputStyle::GNU) {
- // With PrintFunctions == FunctionNameKind::LinkageName (default)
- // and UseSymbolTable == true (also default), Symbolizer.symbolizeCode()
+ } else if (OutputStyle == DIPrinter::OutputStyle::GNU) {
+ // With PrintFunctions == FunctionNameKind::LinkageName (default)
+ // and UseSymbolTable == true (also default), Symbolizer.symbolizeCode()
// may override the name of an inlined function with the name of the topmost
// caller function in the inlining chain. This contradicts the existing
// behavior of addr2line. Symbolizer.symbolizeInlinedCode() overrides only
// the topmost function, which suits our needs better.
auto ResOrErr = Symbolizer.symbolizeInlinedCode(
ModuleName, {Offset, object::SectionedAddress::UndefSection});
- if (!ResOrErr || ResOrErr->getNumberOfFrames() == 0) {
- error(ResOrErr);
- Printer << DILineInfo();
- } else {
- Printer << ResOrErr->getFrame(0);
- }
+ if (!ResOrErr || ResOrErr->getNumberOfFrames() == 0) {
+ error(ResOrErr);
+ Printer << DILineInfo();
+ } else {
+ Printer << ResOrErr->getFrame(0);
+ }
} else {
auto ResOrErr = Symbolizer.symbolizeCode(
ModuleName, {Offset, object::SectionedAddress::UndefSection});
Printer << (error(ResOrErr) ? DILineInfo() : ResOrErr.get());
}
- if (OutputStyle == DIPrinter::OutputStyle::LLVM)
+ if (OutputStyle == DIPrinter::OutputStyle::LLVM)
outs() << "\n";
}
-static void printHelp(StringRef ToolName, const SymbolizerOptTable &Tbl,
- raw_ostream &OS) {
- const char HelpText[] = " [options] addresses...";
- Tbl.PrintHelp(OS, (ToolName + HelpText).str().c_str(),
- ToolName.str().c_str());
- // TODO Replace this with OptTable API once it adds extrahelp support.
- OS << "\nPass @FILE as argument to read options from FILE.\n";
-}
+static void printHelp(StringRef ToolName, const SymbolizerOptTable &Tbl,
+ raw_ostream &OS) {
+ const char HelpText[] = " [options] addresses...";
+ Tbl.PrintHelp(OS, (ToolName + HelpText).str().c_str(),
+ ToolName.str().c_str());
+ // TODO Replace this with OptTable API once it adds extrahelp support.
+ OS << "\nPass @FILE as argument to read options from FILE.\n";
+}
-static opt::InputArgList parseOptions(int Argc, char *Argv[], bool IsAddr2Line,
- StringSaver &Saver,
- SymbolizerOptTable &Tbl) {
- StringRef ToolName = IsAddr2Line ? "llvm-addr2line" : "llvm-symbolizer";
- Tbl.setGroupedShortOptions(true);
- // The environment variable specifies initial options which can be overridden
- // by commnad line options.
- Tbl.setInitialOptionsFromEnvironment(IsAddr2Line ? "LLVM_ADDR2LINE_OPTS"
- : "LLVM_SYMBOLIZER_OPTS");
- bool HasError = false;
- opt::InputArgList Args =
- Tbl.parseArgs(Argc, Argv, OPT_UNKNOWN, Saver, [&](StringRef Msg) {
- errs() << ("error: " + Msg + "\n");
- HasError = true;
- });
- if (HasError)
- exit(1);
- if (Args.hasArg(OPT_help)) {
- printHelp(ToolName, Tbl, outs());
- exit(0);
- }
- if (Args.hasArg(OPT_version)) {
- outs() << ToolName << '\n';
- cl::PrintVersionMessage();
- exit(0);
- }
+static opt::InputArgList parseOptions(int Argc, char *Argv[], bool IsAddr2Line,
+ StringSaver &Saver,
+ SymbolizerOptTable &Tbl) {
+ StringRef ToolName = IsAddr2Line ? "llvm-addr2line" : "llvm-symbolizer";
+ Tbl.setGroupedShortOptions(true);
+ // The environment variable specifies initial options which can be overridden
+ // by commnad line options.
+ Tbl.setInitialOptionsFromEnvironment(IsAddr2Line ? "LLVM_ADDR2LINE_OPTS"
+ : "LLVM_SYMBOLIZER_OPTS");
+ bool HasError = false;
+ opt::InputArgList Args =
+ Tbl.parseArgs(Argc, Argv, OPT_UNKNOWN, Saver, [&](StringRef Msg) {
+ errs() << ("error: " + Msg + "\n");
+ HasError = true;
+ });
+ if (HasError)
+ exit(1);
+ if (Args.hasArg(OPT_help)) {
+ printHelp(ToolName, Tbl, outs());
+ exit(0);
+ }
+ if (Args.hasArg(OPT_version)) {
+ outs() << ToolName << '\n';
+ cl::PrintVersionMessage();
+ exit(0);
+ }
- return Args;
-}
-
-template <typename T>
-static void parseIntArg(const opt::InputArgList &Args, int ID, T &Value) {
- if (const opt::Arg *A = Args.getLastArg(ID)) {
- StringRef V(A->getValue());
- if (!llvm::to_integer(V, Value, 0)) {
- errs() << A->getSpelling() +
- ": expected a non-negative integer, but got '" + V + "'";
- exit(1);
- }
- } else {
- Value = 0;
+ return Args;
+}
+
+template <typename T>
+static void parseIntArg(const opt::InputArgList &Args, int ID, T &Value) {
+ if (const opt::Arg *A = Args.getLastArg(ID)) {
+ StringRef V(A->getValue());
+ if (!llvm::to_integer(V, Value, 0)) {
+ errs() << A->getSpelling() +
+ ": expected a non-negative integer, but got '" + V + "'";
+ exit(1);
+ }
+ } else {
+ Value = 0;
}
-}
+}
-static FunctionNameKind decideHowToPrintFunctions(const opt::InputArgList &Args,
- bool IsAddr2Line) {
- if (Args.hasArg(OPT_functions))
- return FunctionNameKind::LinkageName;
- if (const opt::Arg *A = Args.getLastArg(OPT_functions_EQ))
- return StringSwitch<FunctionNameKind>(A->getValue())
- .Case("none", FunctionNameKind::None)
- .Case("short", FunctionNameKind::ShortName)
- .Default(FunctionNameKind::LinkageName);
- return IsAddr2Line ? FunctionNameKind::None : FunctionNameKind::LinkageName;
-}
+static FunctionNameKind decideHowToPrintFunctions(const opt::InputArgList &Args,
+ bool IsAddr2Line) {
+ if (Args.hasArg(OPT_functions))
+ return FunctionNameKind::LinkageName;
+ if (const opt::Arg *A = Args.getLastArg(OPT_functions_EQ))
+ return StringSwitch<FunctionNameKind>(A->getValue())
+ .Case("none", FunctionNameKind::None)
+ .Case("short", FunctionNameKind::ShortName)
+ .Default(FunctionNameKind::LinkageName);
+ return IsAddr2Line ? FunctionNameKind::None : FunctionNameKind::LinkageName;
+}
-int main(int argc, char **argv) {
- InitLLVM X(argc, argv);
- sys::InitializeCOMRAII COM(sys::COMThreadingMode::MultiThreaded);
-
- bool IsAddr2Line = sys::path::stem(argv[0]).contains("addr2line");
- BumpPtrAllocator A;
- StringSaver Saver(A);
- SymbolizerOptTable Tbl;
- opt::InputArgList Args = parseOptions(argc, argv, IsAddr2Line, Saver, Tbl);
+int main(int argc, char **argv) {
+ InitLLVM X(argc, argv);
+ sys::InitializeCOMRAII COM(sys::COMThreadingMode::MultiThreaded);
+ bool IsAddr2Line = sys::path::stem(argv[0]).contains("addr2line");
+ BumpPtrAllocator A;
+ StringSaver Saver(A);
+ SymbolizerOptTable Tbl;
+ opt::InputArgList Args = parseOptions(argc, argv, IsAddr2Line, Saver, Tbl);
+
LLVMSymbolizer::Options Opts;
- uint64_t AdjustVMA;
- unsigned SourceContextLines;
- parseIntArg(Args, OPT_adjust_vma_EQ, AdjustVMA);
- if (const opt::Arg *A = Args.getLastArg(OPT_basenames, OPT_relativenames)) {
- Opts.PathStyle =
- A->getOption().matches(OPT_basenames)
- ? DILineInfoSpecifier::FileLineInfoKind::BaseNameOnly
- : DILineInfoSpecifier::FileLineInfoKind::RelativeFilePath;
- } else {
- Opts.PathStyle = DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath;
- }
- Opts.DebugFileDirectory = Args.getAllArgValues(OPT_debug_file_directory_EQ);
- Opts.DefaultArch = Args.getLastArgValue(OPT_default_arch_EQ).str();
- Opts.Demangle = Args.hasFlag(OPT_demangle, OPT_no_demangle, !IsAddr2Line);
- Opts.DWPName = Args.getLastArgValue(OPT_dwp_EQ).str();
- Opts.FallbackDebugPath =
- Args.getLastArgValue(OPT_fallback_debug_path_EQ).str();
- Opts.PrintFunctions = decideHowToPrintFunctions(Args, IsAddr2Line);
- parseIntArg(Args, OPT_print_source_context_lines_EQ, SourceContextLines);
- Opts.RelativeAddresses = Args.hasArg(OPT_relative_address);
- Opts.UntagAddresses =
- Args.hasFlag(OPT_untag_addresses, OPT_no_untag_addresses, !IsAddr2Line);
- Opts.UseDIA = Args.hasArg(OPT_use_dia);
-#if !defined(LLVM_ENABLE_DIA_SDK)
- if (Opts.UseDIA) {
- WithColor::warning() << "DIA not available; using native PDB reader\n";
- Opts.UseDIA = false;
- }
-#endif
- Opts.UseSymbolTable = true;
+ uint64_t AdjustVMA;
+ unsigned SourceContextLines;
+ parseIntArg(Args, OPT_adjust_vma_EQ, AdjustVMA);
+ if (const opt::Arg *A = Args.getLastArg(OPT_basenames, OPT_relativenames)) {
+ Opts.PathStyle =
+ A->getOption().matches(OPT_basenames)
+ ? DILineInfoSpecifier::FileLineInfoKind::BaseNameOnly
+ : DILineInfoSpecifier::FileLineInfoKind::RelativeFilePath;
+ } else {
+ Opts.PathStyle = DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath;
+ }
+ Opts.DebugFileDirectory = Args.getAllArgValues(OPT_debug_file_directory_EQ);
+ Opts.DefaultArch = Args.getLastArgValue(OPT_default_arch_EQ).str();
+ Opts.Demangle = Args.hasFlag(OPT_demangle, OPT_no_demangle, !IsAddr2Line);
+ Opts.DWPName = Args.getLastArgValue(OPT_dwp_EQ).str();
+ Opts.FallbackDebugPath =
+ Args.getLastArgValue(OPT_fallback_debug_path_EQ).str();
+ Opts.PrintFunctions = decideHowToPrintFunctions(Args, IsAddr2Line);
+ parseIntArg(Args, OPT_print_source_context_lines_EQ, SourceContextLines);
+ Opts.RelativeAddresses = Args.hasArg(OPT_relative_address);
+ Opts.UntagAddresses =
+ Args.hasFlag(OPT_untag_addresses, OPT_no_untag_addresses, !IsAddr2Line);
+ Opts.UseDIA = Args.hasArg(OPT_use_dia);
+#if !defined(LLVM_ENABLE_DIA_SDK)
+ if (Opts.UseDIA) {
+ WithColor::warning() << "DIA not available; using native PDB reader\n";
+ Opts.UseDIA = false;
+ }
+#endif
+ Opts.UseSymbolTable = true;
- for (const opt::Arg *A : Args.filtered(OPT_dsym_hint_EQ)) {
- StringRef Hint(A->getValue());
- if (sys::path::extension(Hint) == ".dSYM") {
- Opts.DsymHints.emplace_back(Hint);
+ for (const opt::Arg *A : Args.filtered(OPT_dsym_hint_EQ)) {
+ StringRef Hint(A->getValue());
+ if (sys::path::extension(Hint) == ".dSYM") {
+ Opts.DsymHints.emplace_back(Hint);
} else {
- errs() << "Warning: invalid dSYM hint: \"" << Hint
- << "\" (must have the '.dSYM' extension).\n";
+ errs() << "Warning: invalid dSYM hint: \"" << Hint
+ << "\" (must have the '.dSYM' extension).\n";
}
}
-
- auto OutputStyle =
- IsAddr2Line ? DIPrinter::OutputStyle::GNU : DIPrinter::OutputStyle::LLVM;
- if (const opt::Arg *A = Args.getLastArg(OPT_output_style_EQ)) {
- OutputStyle = strcmp(A->getValue(), "GNU") == 0
- ? DIPrinter::OutputStyle::GNU
- : DIPrinter::OutputStyle::LLVM;
- }
-
+
+ auto OutputStyle =
+ IsAddr2Line ? DIPrinter::OutputStyle::GNU : DIPrinter::OutputStyle::LLVM;
+ if (const opt::Arg *A = Args.getLastArg(OPT_output_style_EQ)) {
+ OutputStyle = strcmp(A->getValue(), "GNU") == 0
+ ? DIPrinter::OutputStyle::GNU
+ : DIPrinter::OutputStyle::LLVM;
+ }
+
LLVMSymbolizer Symbolizer(Opts);
- DIPrinter Printer(outs(), Opts.PrintFunctions != FunctionNameKind::None,
- Args.hasArg(OPT_pretty_print), SourceContextLines,
- Args.hasArg(OPT_verbose), OutputStyle);
+ DIPrinter Printer(outs(), Opts.PrintFunctions != FunctionNameKind::None,
+ Args.hasArg(OPT_pretty_print), SourceContextLines,
+ Args.hasArg(OPT_verbose), OutputStyle);
- std::vector<std::string> InputAddresses = Args.getAllArgValues(OPT_INPUT);
- if (InputAddresses.empty()) {
+ std::vector<std::string> InputAddresses = Args.getAllArgValues(OPT_INPUT);
+ if (InputAddresses.empty()) {
const int kMaxInputStringLength = 1024;
char InputString[kMaxInputStringLength];
while (fgets(InputString, sizeof(InputString), stdin)) {
// Strip newline characters.
std::string StrippedInputString(InputString);
- llvm::erase_if(StrippedInputString,
- [](char c) { return c == '\r' || c == '\n'; });
- symbolizeInput(Args, AdjustVMA, IsAddr2Line, OutputStyle,
- StrippedInputString, Symbolizer, Printer);
+ llvm::erase_if(StrippedInputString,
+ [](char c) { return c == '\r' || c == '\n'; });
+ symbolizeInput(Args, AdjustVMA, IsAddr2Line, OutputStyle,
+ StrippedInputString, Symbolizer, Printer);
outs().flush();
}
} else {
- for (StringRef Address : InputAddresses)
- symbolizeInput(Args, AdjustVMA, IsAddr2Line, OutputStyle, Address,
- Symbolizer, Printer);
+ for (StringRef Address : InputAddresses)
+ symbolizeInput(Args, AdjustVMA, IsAddr2Line, OutputStyle, Address,
+ Symbolizer, Printer);
}
return 0;
diff --git a/contrib/libs/llvm12/tools/llvm-symbolizer/ya.make b/contrib/libs/llvm12/tools/llvm-symbolizer/ya.make
index 1f13f78269..1c060ecda0 100644
--- a/contrib/libs/llvm12/tools/llvm-symbolizer/ya.make
+++ b/contrib/libs/llvm12/tools/llvm-symbolizer/ya.make
@@ -12,30 +12,30 @@ LICENSE(Apache-2.0 WITH LLVM-exception)
LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
PEERDIR(
- contrib/libs/llvm12
- contrib/libs/llvm12/include
- contrib/libs/llvm12/lib/BinaryFormat
- contrib/libs/llvm12/lib/Bitcode/Reader
- contrib/libs/llvm12/lib/Bitstream/Reader
- contrib/libs/llvm12/lib/DebugInfo/CodeView
- contrib/libs/llvm12/lib/DebugInfo/DWARF
- contrib/libs/llvm12/lib/DebugInfo/MSF
- contrib/libs/llvm12/lib/DebugInfo/PDB
- contrib/libs/llvm12/lib/DebugInfo/Symbolize
- contrib/libs/llvm12/lib/Demangle
- contrib/libs/llvm12/lib/IR
- contrib/libs/llvm12/lib/MC
- contrib/libs/llvm12/lib/MC/MCParser
- contrib/libs/llvm12/lib/Object
- contrib/libs/llvm12/lib/Option
- contrib/libs/llvm12/lib/Remarks
- contrib/libs/llvm12/lib/Support
- contrib/libs/llvm12/lib/TextAPI/MachO
+ contrib/libs/llvm12
+ contrib/libs/llvm12/include
+ contrib/libs/llvm12/lib/BinaryFormat
+ contrib/libs/llvm12/lib/Bitcode/Reader
+ contrib/libs/llvm12/lib/Bitstream/Reader
+ contrib/libs/llvm12/lib/DebugInfo/CodeView
+ contrib/libs/llvm12/lib/DebugInfo/DWARF
+ contrib/libs/llvm12/lib/DebugInfo/MSF
+ contrib/libs/llvm12/lib/DebugInfo/PDB
+ contrib/libs/llvm12/lib/DebugInfo/Symbolize
+ contrib/libs/llvm12/lib/Demangle
+ contrib/libs/llvm12/lib/IR
+ contrib/libs/llvm12/lib/MC
+ contrib/libs/llvm12/lib/MC/MCParser
+ contrib/libs/llvm12/lib/Object
+ contrib/libs/llvm12/lib/Option
+ contrib/libs/llvm12/lib/Remarks
+ contrib/libs/llvm12/lib/Support
+ contrib/libs/llvm12/lib/TextAPI/MachO
)
ADDINCL(
- ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-symbolizer
- contrib/libs/llvm12/tools/llvm-symbolizer
+ ${ARCADIA_BUILD_ROOT}/contrib/libs/llvm12/tools/llvm-symbolizer
+ contrib/libs/llvm12/tools/llvm-symbolizer
)
NO_COMPILER_WARNINGS()