[llvm-bugs] [Bug 43935] New: --add-symbol produces invalid symbol table for ELF with program headers and no symbol table

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Nov 7 09:03:53 PST 2019


https://bugs.llvm.org/show_bug.cgi?id=43935

            Bug ID: 43935
           Summary: --add-symbol produces invalid symbol table for ELF
                    with program headers and no symbol table
           Product: tools
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: llvm-objcopy/strip
          Assignee: unassignedbugs at nondot.org
          Reporter: jh7370.2008 at my.bristol.ac.uk
                CC: alexander.v.shaposhnikov at gmail.com,
                    jake.h.ehrlich at gmail.com,
                    jh7370.2008 at my.bristol.ac.uk,
                    llvm-bugs at lists.llvm.org, rupprecht at google.com

If you attempt to add a symbol to an ELF with no symbol table, a symbol table
is created. However, if there are program headers, the offset of that symbol
table is invalid (uint64_t max):

## test.yaml:
--- !ELF
FileHeader:
  Class:   ELFCLASS64
  Data:    ELFDATA2LSB
  Type:    ET_DYN
  Machine: EM_X86_64
Sections:
  - Name:    .foo
    Type:    SHT_PROGBITS
ProgramHeaders:
  - Type: PT_LOAD
    Sections:
      - Section: .foo

C:\Work> yaml2obj test.yaml -o test.elf
C:\Work> llvm-objcopy test.elf test2.elf --add-symbol foo=1234
C:\Work> llvm-readelf test2.elf --sections
There are 5 section headers, starting at offset 0xa0:

Section Headers:
  [Nr] Name              Type            Address          Off    Size   ES Flg
Lk Inf Al
  [ 0]                   NULL            0000000000000000 000000 000000 00     
0   0  0
  [ 1] .foo              PROGBITS        0000000000000000 000078 000000 00     
0   0  0
  [ 2] .strtab           STRTAB          0000000000000000 000078 000005 00     
0   0  1
  [ 3] .shstrtab         STRTAB          0000000000000000 00007d 000020 00     
0   0  1
  [ 4] .symtab           SYMTAB          0000000000000000 ffffffffffffffff
000030 18      2   1  8

This is not an issue if there are no program headers (the offset of the symbol
table is correct).

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20191107/934ec5d1/attachment.html>


More information about the llvm-bugs mailing list