<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - --add-symbol produces invalid symbol table for ELF with program headers and no symbol table"
href="https://bugs.llvm.org/show_bug.cgi?id=43935">43935</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>--add-symbol produces invalid symbol table for ELF with program headers and no symbol table
</td>
</tr>
<tr>
<th>Product</th>
<td>tools
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>llvm-objcopy/strip
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>jh7370.2008@my.bristol.ac.uk
</td>
</tr>
<tr>
<th>CC</th>
<td>alexander.v.shaposhnikov@gmail.com, jake.h.ehrlich@gmail.com, jh7370.2008@my.bristol.ac.uk, llvm-bugs@lists.llvm.org, rupprecht@google.com
</td>
</tr></table>
<p>
<div>
<pre>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).</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>