[PATCH] D102258: Fixed llvm-objcopy to add correct symbol table for ELF with program headers.
Alex Orlov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 12 01:39:54 PDT 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd8e65585f7c7: Fixed llvm-objcopy to add correct symbol table for ELF with program headers. (authored by aorlov).
Changed prior to commit:
https://reviews.llvm.org/D102258?vs=344469&id=344714#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D102258/new/
https://reviews.llvm.org/D102258
Files:
llvm/test/tools/llvm-objcopy/ELF/add-symbol-no-symtab.test
llvm/tools/llvm-objcopy/ELF/Object.cpp
Index: llvm/tools/llvm-objcopy/ELF/Object.cpp
===================================================================
--- llvm/tools/llvm-objcopy/ELF/Object.cpp
+++ llvm/tools/llvm-objcopy/ELF/Object.cpp
@@ -1205,6 +1205,10 @@
// not the first.
uint64_t SecSize = Sec.Size ? Sec.Size : 1;
+ // Ignore just added sections.
+ if (Sec.OriginalOffset == std::numeric_limits<uint64_t>::max())
+ return false;
+
if (Sec.Type == SHT_NOBITS) {
if (!(Sec.Flags & SHF_ALLOC))
return false;
Index: llvm/test/tools/llvm-objcopy/ELF/add-symbol-no-symtab.test
===================================================================
--- llvm/test/tools/llvm-objcopy/ELF/add-symbol-no-symtab.test
+++ llvm/test/tools/llvm-objcopy/ELF/add-symbol-no-symtab.test
@@ -105,3 +105,26 @@
Binding: STB_GLOBAL
Symbols: []
...
+
+## Check the created .symtab is correct when there are program headers.
+# RUN: yaml2obj --docnum=4 %s -o %t4
+# RUN: llvm-objcopy %t4 %t4.add --add-symbol foo=1234
+# RUN: llvm-readelf -s %t4.add | FileCheck --check-prefix=SEC4 %s
+
+# SEC4: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
+# SEC4-NEXT: 1: 00000000000004d2 0 NOTYPE GLOBAL DEFAULT ABS foo
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_DYN
+ Machine: EM_X86_64
+Sections:
+ - Name: .foo
+ Type: SHT_PROGBITS
+ProgramHeaders:
+ - Type: PT_LOAD
+ FirstSec: .foo
+ LastSec: .foo
+...
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102258.344714.patch
Type: text/x-patch
Size: 1463 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210512/9ab00998/attachment.bin>
More information about the llvm-commits
mailing list