<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 - llvm-objcopy should strip undefined symbols if they are no longer referenced following --only-section"
href="https://bugs.llvm.org/show_bug.cgi?id=40004">40004</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>llvm-objcopy should strip undefined symbols if they are no longer referenced following --only-section
</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
</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>This may apply more widely when stripping specific sections, but I've not
tried. Currently, llvm-objcopy does not remove undefined symbols if the section
with the source of the reference (i.e. a relocation section) is stripped
following --only-section. This will make the object unusable for linking, even
though it probably should be usable under certain situations. It also is
different to what GNU objcopy does:
Input:
// bar.cpp
extern int bar;
int main(){
return bar;
}
Build with:
clang.exe --target=x86_64-pc-linux -c bar.cpp -g
GNU:
objcopy -j .debug_str bar.o foo.o
readelf foo.o -s
Symbol table '.symtab' contains 2 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
1: 0000000000000000 0 SECTION LOCAL DEFAULT 1
LLVM:
llvm-objcopy bar.o foo.o -j .debug_str
readelf -s foo.o
Symbol table '.symtab' contains 4 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
1: 0000000000000000 0 FILE LOCAL DEFAULT ABS bar.cpp
2: 0000000000000000 0 SECTION LOCAL DEFAULT 1
3: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND bar <-- BAD</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>