<html>
<head>
</head>
<body bgcolor="#FFFFFF" text="#000000">
Joerg:<br>
<blockquote type="cite"><font size="2">How do you then make sure to
not export redundant symbols? Consider<br>
_GLOBAL_OFFSET_TABLE_ -- if the only user is in a dead function,
it<br>
should not be in the symbol table. Same for __tls_get_addr.<br>
</font></blockquote>
I agree that dead code elimination needs additional consideration,
but my problem is that lld pollutes the symbol table inserting
symbols unconditionally. I'd want to find a solution to this problem
first as it generates even more redundant symbols right now.<br>
<br>
Rui:<br>
<blockquote type="cite">
<div>I don't know if this is directly applicable to your problem,
but for PE/COFF I needed to add symbols conditionally. If you
have a function <i>func</i> and if there's a reference to
__imp_<i>func</i>, linker needs to create a data containing the
address of func as __imp_func content. It's rarely used, so I
wanted to create the __imp_ atom only when there's an unresolved
reference to that symbol.</div>
<div><br>
</div>
<div>What I did at that moment is to define a (virtual) library
file which dynamically creates an atom. The virtual library file
is added at end of the input file list, and if the core linker
looks it up for a symbol starting __imp_, the library creates an
object file containing the symbol on the fly and returns it.</div>
<div><br>
</div>
<div>My experience of doing that is that worked but might have
been too tricky. If this trick is directly applicable to your
problem, you may want to do that. If not, I'm perhaps okay with
your suggestion (although I didn't think about that hard yet.)</div>
</blockquote>
Looks like your trick won't work for me, because the virtual library
you add is parsed in the Resolver::resolve() method where I don't
have enough knowledge whether to add specific symbols or not. My
problem is that I can only do it in the relocation pass (or some
other pass if needed), which goes after symbol resolution.<br>
<br>
Thanks,<br>
Denis.<br>
</body>
</html>