diff options
author | Armando Montanez <amontanez@google.com> | 2019-01-16 17:47:16 +0000 |
---|---|---|
committer | Armando Montanez <amontanez@google.com> | 2019-01-16 17:47:16 +0000 |
commit | 4777a84399a5d745283944ce6cd962442b5f504a (patch) | |
tree | bc58c7b3904006a68485a63d39c80cfe50ba207c | |
parent | f4bf1161c0fc5bb5e2b1bd6f2bfdf954eb2bfad5 (diff) |
[elfabi] Add support for reading DT_SONAME from binarieslinaro-local/ci/tcwg_kernel/llvm-master-aarch64-next-allnoconfig
This change gives the llvm-elfabi tool the ability to read DT_SONAME from a binary ELF file into an ELFStub.
Added:
- DynamicEntries struct for storing dynamic entries that are relevant to elfabi.
- terminatedSubstr() retrieves a null-terminated substring from a StringRef.
- appendToError() appends a string to an error, allowing more specific error messages.
Differential Revision: https://reviews.llvm.org/D55629
12 files changed, 537 insertions, 20 deletions
diff --git a/llvm/test/tools/llvm-elfabi/binary-read-add-soname.test b/llvm/test/tools/llvm-elfabi/binary-read-add-soname.test new file mode 100644 index 00000000000..dbc5a00bb57 --- /dev/null +++ b/llvm/test/tools/llvm-elfabi/binary-read-add-soname.test @@ -0,0 +1,48 @@ +# RUN: yaml2obj %s > %t +# RUN: llvm-elfabi --elf %t --emit-tbe=- --soname=best.so | FileCheck %s + +!ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_DYN + Machine: EM_AARCH64 +Sections: + - Name: .dynstr + Type: SHT_STRTAB + Flags: [ SHF_ALLOC ] + Address: 0x0000 + Content: "00" + - Name: .dynamic + Type: SHT_DYNAMIC + Flags: [ SHF_ALLOC ] + Address: 0x0008 + AddressAlign: 8 + Content: "0a0000000000000001000000000000000500000000000000000000000000000000000000000000000000000000000000" + # DT_STRSZ 1 (0x1) + # DT_STRTAB 0x0 + # DT_NULL 0x0 + Size: 48 + Link: .dynstr +ProgramHeaders: + - Type: PT_LOAD + Flags: [ PF_R ] + VAddr: 0x0000 + PAddr: 0x0000 + Align: 8 + Sections: + - Section: .dynstr + - Section: .dynamic + - Type: PT_DYNAMIC + Flags: [ PF_X, PF_R ] + VAddr: 0x0008 + PAddr: 0x0008 + Sections: + - Section: .dynamic + +# CHECK: --- !tapi-tbe +# CHECK-NEXT: TbeVersion: {{[1-9]\d*\.(0|([1-9]\d*))}} +# CHECK-NEXT: SoName: best.so{{$}} +# CHECK-NEXT: Arch: AArch64 +# CHECK-NEXT: Symbols: {} +# CHECK-NEXT: ... diff --git a/llvm/test/tools/llvm-elfabi/binary-read-arch.test b/llvm/test/tools/llvm-elfabi/binary-read-arch.test index ecb2fb81446..f2c2d8bd56d 100644 --- a/llvm/test/tools/llvm-elfabi/binary-read-arch.test +++ b/llvm/test/tools/llvm-elfabi/binary-read-arch.test @@ -1,5 +1,5 @@ # RUN: yaml2obj %s > %t -# RUN: llvm-elfabi %t --emit-tbe=- | FileCheck %s +# RUN: llvm-elfabi --elf %t --emit-tbe=- | FileCheck %s !ELF FileHeader: @@ -7,6 +7,38 @@ FileHeader: Data: ELFDATA2LSB Type: ET_DYN Machine: EM_X86_64 +Sections: + - Name: .dynstr + Type: SHT_STRTAB + Flags: [ SHF_ALLOC ] + Address: 0x0000 + Content: "00" + - Name: .dynamic + Type: SHT_DYNAMIC + Flags: [ SHF_ALLOC ] + Address: 0x0008 + AddressAlign: 8 + Content: "0a0000000000000001000000000000000500000000000000000000000000000000000000000000000000000000000000" + # DT_STRSZ 1 (0x1) + # DT_STRTAB 0x0 + # DT_NULL 0x0 + Size: 48 + Link: .dynstr +ProgramHeaders: + - Type: PT_LOAD + Flags: [ PF_R ] + VAddr: 0x0000 + PAddr: 0x0000 + Align: 8 + Sections: + - Section: .dynstr + - Section: .dynamic + - Type: PT_DYNAMIC + Flags: [ PF_X, PF_R ] + VAddr: 0x0008 + PAddr: 0x0008 + Sections: + - Section: .dynamic # CHECK: --- !tapi-tbe # CHECK-NEXT: TbeVersion: {{[1-9]\d*\.(0|([1-9]\d*))}} diff --git a/llvm/test/tools/llvm-elfabi/binary-read-bad-soname.test b/llvm/test/tools/llvm-elfabi/binary-read-bad-soname.test new file mode 100644 index 00000000000..cc7205b15eb --- /dev/null +++ b/llvm/test/tools/llvm-elfabi/binary-read-bad-soname.test @@ -0,0 +1,44 @@ +# RUN: yaml2obj %s > %t +# RUN: not llvm-elfabi --elf %t --emit-tbe=%t.tbe 2>&1 | FileCheck %s + +!ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_DYN + Machine: EM_X86_64 +Sections: + - Name: .dynstr + Type: SHT_STRTAB + Flags: [ SHF_ALLOC ] + Address: 0x0000 + Content: "00" + - Name: .dynamic + Type: SHT_DYNAMIC + Flags: [ SHF_ALLOC ] + Address: 0x0008 + AddressAlign: 8 + Content: "0e000000000000000d000000000000000a0000000000000001000000000000000500000000000000000000000000000000000000000000000000000000000000" + # DT_SONAME 13 (0x0d) + # DT_STRSZ 1 (0x01) + # DT_STRTAB 0x0 + # DT_NULL 0x0 + Size: 64 + Link: .dynstr +ProgramHeaders: + - Type: PT_LOAD + Flags: [ PF_R ] + VAddr: 0x0000 + PAddr: 0x0000 + Align: 8 + Sections: + - Section: .dynstr + - Section: .dynamic + - Type: PT_DYNAMIC + Flags: [ PF_X, PF_R ] + VAddr: 0x0008 + PAddr: 0x0008 + Sections: + - Section: .dynamic + +# CHECK: DT_SONAME string offset (0x000000000000000d) outside of dynamic string table diff --git a/llvm/test/tools/llvm-elfabi/binary-read-bad-vaddr.test b/llvm/test/tools/llvm-elfabi/binary-read-bad-vaddr.test new file mode 100644 index 00000000000..5dc96df38a2 --- /dev/null +++ b/llvm/test/tools/llvm-elfabi/binary-read-bad-vaddr.test @@ -0,0 +1,44 @@ +# RUN: yaml2obj %s > %t +# RUN: not llvm-elfabi --elf %t --emit-tbe=%t.tbe 2>&1 | FileCheck %s + +!ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_DYN + Machine: EM_X86_64 +Sections: + - Name: .dynstr + Type: SHT_STRTAB + Flags: [ SHF_ALLOC ] + Address: 0x1000 + Content: "00" + - Name: .dynamic + Type: SHT_DYNAMIC + Flags: [ SHF_ALLOC ] + Address: 0x1008 + AddressAlign: 8 + Content: "0e0000000000000000000000000000000a0000000000000001000000000000000500000000000000600200000000000000000000000000000000000000000000" + # DT_SONAME 0 + # DT_STRSZ 1 + # DT_STRTAB 0x0260 # Bad vaddr (no PT_LOAD for 0x0000 to 0x0FFF) + # DT_NULL 0x0 + Size: 64 + Link: .dynstr +ProgramHeaders: + - Type: PT_LOAD + Flags: [ PF_R ] + VAddr: 0x1000 + PAddr: 0x1000 + Align: 8 + Sections: + - Section: .dynstr + - Section: .dynamic + - Type: PT_DYNAMIC + Flags: [ PF_X, PF_R ] + VAddr: 0x1008 + PAddr: 0x1008 + Sections: + - Section: .dynamic + +# CHECK: Virtual address is not in any segment when locating .dynstr section contents diff --git a/llvm/test/tools/llvm-elfabi/binary-read-no-dt-strsz.test b/llvm/test/tools/llvm-elfabi/binary-read-no-dt-strsz.test new file mode 100644 index 00000000000..09e514ad412 --- /dev/null +++ b/llvm/test/tools/llvm-elfabi/binary-read-no-dt-strsz.test @@ -0,0 +1,43 @@ +# RUN: yaml2obj %s > %t +# RUN: not llvm-elfabi --elf %t --emit-tbe=%t.tbe 2>&1 | FileCheck %s + +!ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_DYN + Machine: EM_X86_64 +Sections: + - Name: .dynstr + Type: SHT_STRTAB + Flags: [ SHF_ALLOC ] + Address: 0x0000 +# \0 b a z\0 + Content: "0062617a00" + - Name: .dynamic + Type: SHT_DYNAMIC + Flags: [ SHF_ALLOC ] + Address: 0x0008 + AddressAlign: 8 + Content: "0500000000000000000000000000000000000000000000000000000000000000" + # DT_STRTAB 0x0 + # DT_NULL 0x0 + Size: 32 + Link: .dynstr +ProgramHeaders: + - Type: PT_LOAD + Flags: [ PF_R ] + VAddr: 0x0000 + PAddr: 0x0000 + Align: 8 + Sections: + - Section: .dynstr + - Section: .dynamic + - Type: PT_DYNAMIC + Flags: [ PF_X, PF_R ] + VAddr: 0x0008 + PAddr: 0x0008 + Sections: + - Section: .dynamic + +# CHECK: Couldn't determine dynamic string table size (no DT_STRSZ entry) diff --git a/llvm/test/tools/llvm-elfabi/binary-read-no-dt-strtab.test b/llvm/test/tools/llvm-elfabi/binary-read-no-dt-strtab.test new file mode 100644 index 00000000000..25fcbdc2f84 --- /dev/null +++ b/llvm/test/tools/llvm-elfabi/binary-read-no-dt-strtab.test @@ -0,0 +1,42 @@ +# RUN: yaml2obj %s > %t +# RUN: not llvm-elfabi --elf %t --emit-tbe=%t.tbe 2>&1 | FileCheck %s + +!ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_DYN + Machine: EM_X86_64 +Sections: + - Name: .dynstr + Type: SHT_STRTAB + Flags: [ SHF_ALLOC ] + Address: 0x0000 + Content: "00" + - Name: .dynamic + Type: SHT_DYNAMIC + Flags: [ SHF_ALLOC ] + Address: 0x0008 + AddressAlign: 8 + Content: "0a00000000000000010000000000000000000000000000000000000000000000" + # DT_STRSZ 1 (0x1) + # DT_NULL 0x0 + Size: 32 + Link: .dynstr +ProgramHeaders: + - Type: PT_LOAD + Flags: [ PF_R ] + VAddr: 0x0000 + PAddr: 0x0000 + Align: 8 + Sections: + - Section: .dynstr + - Section: .dynamic + - Type: PT_DYNAMIC + Flags: [ PF_X, PF_R ] + VAddr: 0x0008 + PAddr: 0x0008 + Sections: + - Section: .dynamic + +# CHECK: Couldn't locate dynamic string table (no DT_STRTAB entry) diff --git a/llvm/test/tools/llvm-elfabi/binary-read-no-dynamic.test b/llvm/test/tools/llvm-elfabi/binary-read-no-dynamic.test new file mode 100644 index 00000000000..475d7bf7b84 --- /dev/null +++ b/llvm/test/tools/llvm-elfabi/binary-read-no-dynamic.test @@ -0,0 +1,11 @@ +# RUN: yaml2obj %s > %t +# RUN: not llvm-elfabi --elf %t --emit-tbe=%t.tbe 2>&1 | FileCheck %s + +!ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_DYN + Machine: EM_X86_64 + +# CHECK: No .dynamic section found diff --git a/llvm/test/tools/llvm-elfabi/binary-read-replace-soname.test b/llvm/test/tools/llvm-elfabi/binary-read-replace-soname.test new file mode 100644 index 00000000000..23f0ba3308e --- /dev/null +++ b/llvm/test/tools/llvm-elfabi/binary-read-replace-soname.test @@ -0,0 +1,48 @@ +# RUN: yaml2obj %s > %t +# RUN: llvm-elfabi --elf %t --emit-tbe=- | FileCheck %s --check-prefix=ORIGINAL +# RUN: llvm-elfabi --elf %t --emit-tbe=- --soname=libbest.so | FileCheck %s --check-prefix=REPLACED + +!ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_DYN + Machine: EM_X86_64 +Sections: + - Name: .dynstr + Type: SHT_STRTAB + Flags: [ SHF_ALLOC ] + Address: 0x1000 +# \0 b a z\0 s o m e l i b . s o\0 f o o\0 + Content: "0062617a00736f6d656c69622e736f00666f6f00" + - Name: .dynamic + Type: SHT_DYNAMIC + Flags: [ SHF_ALLOC ] + Address: 0x1018 + AddressAlign: 8 + Content: "0e0000000000000005000000000000000a0000000000000014000000000000000500000000000000001000000000000000000000000000000000000000000000" + # DT_SONAME 5 (0x05) + # DT_STRSZ 20 (0x14) + # DT_STRTAB 0x1000 + # DT_NULL 0x0 + Size: 64 + Link: .dynstr +ProgramHeaders: + - Type: PT_LOAD + Flags: [ PF_R ] + VAddr: 0x1000 + PAddr: 0x1000 + Align: 8 + Sections: + - Section: .dynstr + - Section: .dynamic + - Type: PT_DYNAMIC + Flags: [ PF_X, PF_R ] + VAddr: 0x1018 + PAddr: 0x1018 + Sections: + - Section: .dynamic + +# ORIGINAL: SoName: somelib.so{{$}} + +# REPLACED: SoName: libbest.so{{$}} diff --git a/llvm/test/tools/llvm-elfabi/binary-read-soname-no-null.test b/llvm/test/tools/llvm-elfabi/binary-read-soname-no-null.test new file mode 100644 index 00000000000..224407d9310 --- /dev/null +++ b/llvm/test/tools/llvm-elfabi/binary-read-soname-no-null.test @@ -0,0 +1,45 @@ +# RUN: yaml2obj %s > %t +# RUN: not llvm-elfabi --elf %t --emit-tbe=%t.tbe 2>&1 | FileCheck %s + +!ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_DYN + Machine: EM_X86_64 +Sections: + - Name: .dynstr + Type: SHT_STRTAB + Flags: [ SHF_ALLOC ] + Address: 0x1000 +# \0 b a z\0 s o m e l i b . s o z z z + Content: "0062617a00736f6d656c69622e736f7a7a7a" + - Name: .dynamic + Type: SHT_DYNAMIC + Flags: [ SHF_ALLOC ] + Address: 0x1018 + AddressAlign: 8 + Content: "0e0000000000000005000000000000000a000000000000000f000000000000000500000000000000001000000000000000000000000000000000000000000000" + # DT_SONAME 5 (0x05) + # DT_STRSZ 15 (0x0F) + # DT_STRTAB 0x1000 + # DT_NULL 0x0 + Size: 64 + Link: .dynstr +ProgramHeaders: + - Type: PT_LOAD + Flags: [ PF_R ] + VAddr: 0x1000 + PAddr: 0x1000 + Align: 8 + Sections: + - Section: .dynstr + - Section: .dynamic + - Type: PT_DYNAMIC + Flags: [ PF_X, PF_R ] + VAddr: 0x1018 + PAddr: 0x1018 + Sections: + - Section: .dynamic + +# CHECK: String overran bounds of string table (no null terminator) when reading DT_SONAME diff --git a/llvm/test/tools/llvm-elfabi/binary-read-soname.test b/llvm/test/tools/llvm-elfabi/binary-read-soname.test new file mode 100644 index 00000000000..b6877c64bdc --- /dev/null +++ b/llvm/test/tools/llvm-elfabi/binary-read-soname.test @@ -0,0 +1,50 @@ +# RUN: yaml2obj %s > %t +# RUN: llvm-elfabi --elf %t --emit-tbe=- | FileCheck %s + +!ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_DYN + Machine: EM_X86_64 +Sections: + - Name: .dynstr + Type: SHT_STRTAB + Flags: [ SHF_ALLOC ] + Address: 0x1000 +# \0 b a z\0 s o m e l i b . s o\0 f o o\0 + Content: "0062617a00736f6d656c69622e736f00666f6f00" + - Name: .dynamic + Type: SHT_DYNAMIC + Flags: [ SHF_ALLOC ] + Address: 0x1018 + AddressAlign: 8 + Content: "0e0000000000000005000000000000000a0000000000000014000000000000000500000000000000001000000000000000000000000000000000000000000000" + # DT_SONAME 5 (0x05) + # DT_STRSZ 20 (0x14) + # DT_STRTAB 0x1000 + # DT_NULL 0x0 + Size: 64 + Link: .dynstr +ProgramHeaders: + - Type: PT_LOAD + Flags: [ PF_R ] + VAddr: 0x1000 + PAddr: 0x1000 + Align: 8 + Sections: + - Section: .dynstr + - Section: .dynamic + - Type: PT_DYNAMIC + Flags: [ PF_X, PF_R ] + VAddr: 0x1018 + PAddr: 0x1018 + Sections: + - Section: .dynamic + +# CHECK: --- !tapi-tbe +# CHECK-NEXT: TbeVersion: {{[1-9]\d*\.(0|([1-9]\d*))}} +# CHECK-NEXT: SoName: somelib.so{{$}} +# CHECK-NEXT: Arch: x86_64 +# CHECK-NEXT: Symbols: {} +# CHECK-NEXT: ... diff --git a/llvm/test/tools/llvm-elfabi/replace-soname-tbe.test b/llvm/test/tools/llvm-elfabi/replace-soname-tbe.test deleted file mode 100644 index 71d50a83b83..00000000000 --- a/llvm/test/tools/llvm-elfabi/replace-soname-tbe.test +++ /dev/null @@ -1,16 +0,0 @@ -# RUN: yaml2obj %s > %t -# RUN: llvm-elfabi %t --emit-tbe=- --soname=best.so | FileCheck %s - -!ELF -FileHeader: - Class: ELFCLASS64 - Data: ELFDATA2LSB - Type: ET_DYN - Machine: EM_AARCH64 - -# CHECK: --- !tapi-tbe -# CHECK-NEXT: TbeVersion: {{[1-9]\d*\.(0|([1-9]\d*))}} -# CHECK-NEXT: SoName: best.so -# CHECK-NEXT: Arch: AArch64 -# CHECK-NEXT: Symbols: {} -# CHECK-NEXT: ... diff --git a/llvm/tools/llvm-elfabi/ELFObjHandler.cpp b/llvm/tools/llvm-elfabi/ELFObjHandler.cpp index 412c299c1f7..4c8e61db6ac 100644 --- a/llvm/tools/llvm-elfabi/ELFObjHandler.cpp +++ b/llvm/tools/llvm-elfabi/ELFObjHandler.cpp @@ -21,23 +21,149 @@ using llvm::object::ELFObjectFile; using namespace llvm; using namespace llvm::object; -using namespace llvm::elfabi; using namespace llvm::ELF; namespace llvm { namespace elfabi { +// Simple struct to hold relevant .dynamic entries. +struct DynamicEntries { + uint64_t StrTabAddr = 0; + uint64_t StrSize = 0; + Optional<uint64_t> SONameOffset; +}; + +/// This function behaves similarly to StringRef::substr(), but attempts to +/// terminate the returned StringRef at the first null terminator. If no null +/// terminator is found, an error is returned. +/// +/// @param Str Source string to create a substring from. +/// @param Offset The start index of the desired substring. +static Expected<StringRef> terminatedSubstr(StringRef Str, size_t Offset) { + size_t StrEnd = Str.find('\0', Offset); + if (StrEnd == StringLiteral::npos) { + return createError( + "String overran bounds of string table (no null terminator)"); + } + + size_t StrLen = StrEnd - Offset; + return Str.substr(Offset, StrLen); +} + +/// This function takes an error, and appends a string of text to the end of +/// that error. Since "appending" to an Error isn't supported behavior of an +/// Error, this function technically creates a new error with the combined +/// message and consumes the old error. +/// +/// @param Err Source error. +/// @param After Text to append at the end of Err's error message. +Error appendToError(Error Err, StringRef After) { + std::string Message; + raw_string_ostream Stream(Message); + Stream << Err; + Stream << " " << After; + consumeError(std::move(Err)); + return createError(Stream.str().c_str()); +} + +/// This function populates a DynamicEntries struct using an ELFT::DynRange. +/// After populating the struct, the members are validated with +/// some basic sanity checks. +/// +/// @param Dyn Target DynamicEntries struct to populate. +/// @param DynTable Source dynamic table. +template <class ELFT> +static Error populateDynamic(DynamicEntries &Dyn, + typename ELFT::DynRange DynTable) { + if (DynTable.empty()) + return createError("No .dynamic section found"); + + // Search .dynamic for relevant entries. + bool FoundDynStr = false; + bool FoundDynStrSz = false; + for (auto &Entry : DynTable) { + switch (Entry.d_tag) { + case DT_SONAME: + Dyn.SONameOffset = Entry.d_un.d_val; + break; + case DT_STRTAB: + Dyn.StrTabAddr = Entry.d_un.d_ptr; + FoundDynStr = true; + break; + case DT_STRSZ: + Dyn.StrSize = Entry.d_un.d_val; + FoundDynStrSz = true; + break; + } + } + + if (!FoundDynStr) { + return createError( + "Couldn't locate dynamic string table (no DT_STRTAB entry)"); + } + if (!FoundDynStrSz) { + return createError( + "Couldn't determine dynamic string table size (no DT_STRSZ entry)"); + } + if (Dyn.SONameOffset.hasValue() && *Dyn.SONameOffset >= Dyn.StrSize) { + return createStringError( + object_error::parse_failed, + "DT_SONAME string offset (0x%016x) outside of dynamic string table", + *Dyn.SONameOffset); + } + + return Error::success(); +} + /// Returns a new ELFStub with all members populated from an ELFObjectFile. /// @param ElfObj Source ELFObjectFile. template <class ELFT> -Expected<std::unique_ptr<ELFStub>> +static Expected<std::unique_ptr<ELFStub>> buildStub(const ELFObjectFile<ELFT> &ElfObj) { + using Elf_Dyn_Range = typename ELFT::DynRange; + using Elf_Phdr_Range = typename ELFT::PhdrRange; std::unique_ptr<ELFStub> DestStub = make_unique<ELFStub>(); const ELFFile<ELFT> *ElfFile = ElfObj.getELFFile(); + // Fetch .dynamic table. + Expected<Elf_Dyn_Range> DynTable = ElfFile->dynamicEntries(); + if (!DynTable) { + return DynTable.takeError(); + } + + // Fetch program headers. + Expected<Elf_Phdr_Range> PHdrs = ElfFile->program_headers(); + if (!PHdrs) { + return PHdrs.takeError(); + } + + // Collect relevant .dynamic entries. + DynamicEntries DynEnt; + if (Error Err = populateDynamic<ELFT>(DynEnt, *DynTable)) + return std::move(Err); + + // Convert .dynstr address to an offset. + Expected<const uint8_t *> DynStrPtr = + ElfFile->toMappedAddr(DynEnt.StrTabAddr); + if (!DynStrPtr) + return appendToError(DynStrPtr.takeError(), + "when locating .dynstr section contents"); + StringRef DynStr(reinterpret_cast<const char *>(DynStrPtr.get()), + DynEnt.StrSize); + + // Populate Arch from ELF header. DestStub->Arch = ElfFile->getHeader()->e_machine; - // TODO: Populate SoName from .dynamic entries and linked string table. + // Populate SoName from .dynamic entries and dynamic string table. + if (DynEnt.SONameOffset.hasValue()) { + Expected<StringRef> NameOrErr = + terminatedSubstr(DynStr, *DynEnt.SONameOffset); + if (!NameOrErr) { + return appendToError(NameOrErr.takeError(), "when reading DT_SONAME"); + } + DestStub->SoName = *NameOrErr; + } + // TODO: Populate NeededLibs from .dynamic entries and linked string table. // TODO: Populate Symbols from .dynsym table and linked string table. |