aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib
diff options
context:
space:
mode:
authorAndres Villegas <andresvi@google.com>2024-03-19 10:58:31 -0700
committerGitHub <noreply@github.com>2024-03-19 13:58:31 -0400
commit3176c157190c80b4279dec86c4b9b84472d8ccac (patch)
tree31751c0814ab695cf76a6ab63ca23d7612c04512 /llvm/lib
parent4bade55cc65db8b7f977dba4f13bf335e93317a8 (diff)
downloadllvm-3176c157190c80b4279dec86c4b9b84472d8ccac.zip
llvm-3176c157190c80b4279dec86c4b9b84472d8ccac.tar.gz
llvm-3176c157190c80b4279dec86c4b9b84472d8ccac.tar.bz2
Revert "[dsymutil] Remove support for obfuscated bitcode" (#85826)
Reverts llvm/llvm-project#85713 Since it is breaking Linux x64 builds.
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/NonRelocatableStringpool.cpp5
-rw-r--r--llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp4
-rw-r--r--llvm/lib/DWARFLinker/Classic/DWARFStreamer.cpp12
-rw-r--r--llvm/lib/DWARFLinker/Parallel/DWARFLinker.cpp6
-rw-r--r--llvm/lib/DWARFLinker/Parallel/DWARFLinkerGlobalData.h15
-rw-r--r--llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.cpp4
-rw-r--r--llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.h3
-rw-r--r--llvm/lib/DWARFLinker/Parallel/OutputSections.h2
-rw-r--r--llvm/lib/DWARFLinker/Parallel/StringEntryToDwarfStringPoolEntryMap.h2
9 files changed, 40 insertions, 13 deletions
diff --git a/llvm/lib/CodeGen/NonRelocatableStringpool.cpp b/llvm/lib/CodeGen/NonRelocatableStringpool.cpp
index 26857c6..e8391af 100644
--- a/llvm/lib/CodeGen/NonRelocatableStringpool.cpp
+++ b/llvm/lib/CodeGen/NonRelocatableStringpool.cpp
@@ -12,6 +12,8 @@
namespace llvm {
DwarfStringPoolEntryRef NonRelocatableStringpool::getEntry(StringRef S) {
+ if (Translator)
+ S = Translator(S);
auto I = Strings.insert({S, DwarfStringPoolEntry()});
auto &Entry = I.first->second;
if (I.second || !Entry.isIndexed()) {
@@ -26,6 +28,9 @@ DwarfStringPoolEntryRef NonRelocatableStringpool::getEntry(StringRef S) {
StringRef NonRelocatableStringpool::internString(StringRef S) {
DwarfStringPoolEntry Entry{nullptr, 0, DwarfStringPoolEntry::NotIndexed};
+ if (Translator)
+ S = Translator(S);
+
auto InsertResult = Strings.insert({S, Entry});
return InsertResult.first->getKey();
}
diff --git a/llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp b/llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp
index 60f664e..9b581a6 100644
--- a/llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp
+++ b/llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp
@@ -2701,8 +2701,8 @@ Error DWARFLinker::link() {
// This Dwarf string pool which is used for emission. It must be used
// serially as the order of calling getStringOffset matters for
// reproducibility.
- OffsetsStringPool DebugStrPool(true);
- OffsetsStringPool DebugLineStrPool(false);
+ OffsetsStringPool DebugStrPool(StringsTranslator, true);
+ OffsetsStringPool DebugLineStrPool(StringsTranslator, false);
DebugDieValuePool StringOffsetPool;
// ODR Contexts for the optimize.
diff --git a/llvm/lib/DWARFLinker/Classic/DWARFStreamer.cpp b/llvm/lib/DWARFLinker/Classic/DWARFStreamer.cpp
index 8b31b5e..6d52237 100644
--- a/llvm/lib/DWARFLinker/Classic/DWARFStreamer.cpp
+++ b/llvm/lib/DWARFLinker/Classic/DWARFStreamer.cpp
@@ -32,9 +32,10 @@ using namespace dwarf_linker::classic;
Expected<std::unique_ptr<DwarfStreamer>> DwarfStreamer::createStreamer(
const Triple &TheTriple, DWARFLinkerBase::OutputFileType FileType,
- raw_pwrite_stream &OutFile, DWARFLinkerBase::MessageHandlerTy Warning) {
+ raw_pwrite_stream &OutFile, DWARFLinkerBase::TranslatorFuncTy Translator,
+ DWARFLinkerBase::MessageHandlerTy Warning) {
std::unique_ptr<DwarfStreamer> Streamer =
- std::make_unique<DwarfStreamer>(FileType, OutFile, Warning);
+ std::make_unique<DwarfStreamer>(FileType, OutFile, Translator, Warning);
if (Error Err = Streamer->init(TheTriple, "__DWARF"))
return std::move(Err);
@@ -976,10 +977,11 @@ void DwarfStreamer::emitLineTableString(const DWARFDebugLine::Prologue &P,
switch (String.getForm()) {
case dwarf::DW_FORM_string: {
- StringRef Str = *StringVal;
- Asm->OutStreamer->emitBytes(Str.data());
+ StringRef TranslatedString =
+ (Translator) ? Translator(*StringVal) : *StringVal;
+ Asm->OutStreamer->emitBytes(TranslatedString.data());
Asm->emitInt8(0);
- LineSectionSize += Str.size() + 1;
+ LineSectionSize += TranslatedString.size() + 1;
} break;
case dwarf::DW_FORM_strp:
case dwarf::DW_FORM_line_strp: {
diff --git a/llvm/lib/DWARFLinker/Parallel/DWARFLinker.cpp b/llvm/lib/DWARFLinker/Parallel/DWARFLinker.cpp
index 31c7e86..ad8d28a 100644
--- a/llvm/lib/DWARFLinker/Parallel/DWARFLinker.cpp
+++ b/llvm/lib/DWARFLinker/Parallel/DWARFLinker.cpp
@@ -15,6 +15,8 @@ using namespace dwarf_linker::parallel;
std::unique_ptr<DWARFLinker>
DWARFLinker::createLinker(MessageHandlerTy ErrorHandler,
- MessageHandlerTy WarningHandler) {
- return std::make_unique<DWARFLinkerImpl>(ErrorHandler, WarningHandler);
+ MessageHandlerTy WarningHandler,
+ TranslatorFuncTy StringsTranslator) {
+ return std::make_unique<DWARFLinkerImpl>(ErrorHandler, WarningHandler,
+ StringsTranslator);
}
diff --git a/llvm/lib/DWARFLinker/Parallel/DWARFLinkerGlobalData.h b/llvm/lib/DWARFLinker/Parallel/DWARFLinkerGlobalData.h
index 7ca81eb..38c261a 100644
--- a/llvm/lib/DWARFLinker/Parallel/DWARFLinkerGlobalData.h
+++ b/llvm/lib/DWARFLinker/Parallel/DWARFLinkerGlobalData.h
@@ -21,6 +21,7 @@ class DWARFDie;
namespace dwarf_linker {
namespace parallel {
+using TranslatorFuncTy = std::function<StringRef(StringRef)>;
using MessageHandlerTy = std::function<void(
const Twine &Warning, StringRef Context, const DWARFDie *DIE)>;
@@ -94,6 +95,19 @@ public:
/// Returns global string pool.
StringPool &getStringPool() { return Strings; }
+ /// Set translation function.
+ void setTranslator(TranslatorFuncTy Translator) {
+ this->Translator = Translator;
+ }
+
+ /// Translate specified string.
+ StringRef translateString(StringRef String) {
+ if (Translator)
+ return Translator(String);
+
+ return String;
+ }
+
/// Returns linking options.
const DWARFLinkerOptions &getOptions() const { return Options; }
@@ -147,6 +161,7 @@ public:
protected:
llvm::parallel::PerThreadBumpPtrAllocator Allocator;
StringPool Strings;
+ TranslatorFuncTy Translator;
DWARFLinkerOptions Options;
MessageHandlerTy WarningHandler;
MessageHandlerTy ErrorHandler;
diff --git a/llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.cpp b/llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.cpp
index e68bf0c..49b0899 100644
--- a/llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.cpp
+++ b/llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.cpp
@@ -20,9 +20,11 @@ using namespace dwarf_linker;
using namespace dwarf_linker::parallel;
DWARFLinkerImpl::DWARFLinkerImpl(MessageHandlerTy ErrorHandler,
- MessageHandlerTy WarningHandler)
+ MessageHandlerTy WarningHandler,
+ TranslatorFuncTy StringsTranslator)
: UniqueUnitID(0), DebugStrStrings(GlobalData),
DebugLineStrStrings(GlobalData), CommonSections(GlobalData) {
+ GlobalData.setTranslator(StringsTranslator);
GlobalData.setErrorHandler(ErrorHandler);
GlobalData.setWarningHandler(WarningHandler);
}
diff --git a/llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.h b/llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.h
index 597bb1b..7c17c5b 100644
--- a/llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.h
+++ b/llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.h
@@ -26,7 +26,8 @@ namespace parallel {
class DWARFLinkerImpl : public DWARFLinker {
public:
DWARFLinkerImpl(MessageHandlerTy ErrorHandler,
- MessageHandlerTy WarningHandler);
+ MessageHandlerTy WarningHandler,
+ TranslatorFuncTy StringsTranslator);
/// Add object file to be linked. Pre-load compile unit die. Call
/// \p OnCUDieLoaded for each compile unit die. If specified \p File
diff --git a/llvm/lib/DWARFLinker/Parallel/OutputSections.h b/llvm/lib/DWARFLinker/Parallel/OutputSections.h
index 0e1f2da..a21e4b2 100644
--- a/llvm/lib/DWARFLinker/Parallel/OutputSections.h
+++ b/llvm/lib/DWARFLinker/Parallel/OutputSections.h
@@ -253,7 +253,7 @@ struct SectionDescriptor : SectionDescriptorBase {
/// Emit specified inplace string value into the current section contents.
void emitInplaceString(StringRef String) {
- OS << String;
+ OS << GlobalData.translateString(String);
emitIntVal(0, 1);
}
diff --git a/llvm/lib/DWARFLinker/Parallel/StringEntryToDwarfStringPoolEntryMap.h b/llvm/lib/DWARFLinker/Parallel/StringEntryToDwarfStringPoolEntryMap.h
index f67536e..858f224 100644
--- a/llvm/lib/DWARFLinker/Parallel/StringEntryToDwarfStringPoolEntryMap.h
+++ b/llvm/lib/DWARFLinker/Parallel/StringEntryToDwarfStringPoolEntryMap.h
@@ -33,7 +33,7 @@ public:
DwarfStringPoolEntryWithExtString *DataPtr =
GlobalData.getAllocator()
.Allocate<DwarfStringPoolEntryWithExtString>();
- DataPtr->String = String->getKey();
+ DataPtr->String = GlobalData.translateString(String->getKey());
DataPtr->Index = DwarfStringPoolEntry::NotIndexed;
DataPtr->Offset = 0;
DataPtr->Symbol = nullptr;