<div dir="ltr">Hi Jordan,<div><br></div><div>No objections per se, however: </div><div><br></div><div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>However, the actual thing GNU sources for objcopy.c does (simplified to just relevant bits) is this:</div><div><br></div><div><div><font face="monospace, monospace">  for (auto sym : symbols) {</font></div><div><font face="monospace, monospace">    auto flags = sym->flags;</font></div><div><font face="monospace, monospace">    auto name = sym->name;</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">    // If flag is global/weak, and --keep-global-symbol includes it,</font></div><div><font face="monospace, monospace">    // make it local</font></div><div><font face="monospace, monospace">    if ((flags & (GLOBAL | WEAK)) &&</font></div><div><font face="monospace, monospace">        (keep_globals.size() != 0 && !list_contains(keep_globals, name))) {</font></div><div><font face="monospace, monospace">      sym->flags &= ~(GLOBAL | WEAK);</font></div><div><font face="monospace, monospace">      sym->flags |= LOCAL;</font></div><div><font face="monospace, monospace">    }</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">    // If flag is local and --globalize-symbol is set, make it global</font></div><div><font face="monospace, monospace">    // Note: checks flags, not sym->flags</font></div><div><font face="monospace, monospace">    if ((flags & LOCAL) && list_contains(globalize, name)) {</font></div><div><font face="monospace, monospace">      sym->flags &= ~LOCAL;</font></div><div><font face="monospace, monospace">      sym->flags |= GLOBAL;</font></div><div><font face="monospace, monospace">    }</font></div><div><font face="monospace, monospace">  }</font></div></div><div><font face="monospace, monospace"><br></font></div><div>This seems strange for a few reasons:</div><div><br></div><div>* Weak symbols are not globalized. The help for --globalize-symbol never mention it doesn't handle weak symbols, so this seems like a bug in GNU objcopy.</div><div><br></div><div>* If one were to do "--globalize-symbol SomeGlobal --keep-global-symbol SomeOtherGlobal", you might expect that both SomeGlobal and SomeOtherGlobal are global in the output file... but it isn't. (Admittedly, this is a weird command line usage). Because --keep-global-symbol is set and doesn't include SomeGlobal, SomeGlobal will be demoted to a local symbol. And because the check to see if we should apply the --globalize-symbol flag checks "flags" (the original flag set), and not "sym->flags", it decides not to do anything, so SomeGlobal remains a local symbol.</div><div><br></div></div></div></blockquote><div><br></div><div>I'd probably send a message to the binutils list with this (happy to be cc'd on it) with "hey, this behavior and the documentation doesn't match. Do we know of anything that depends on this behavior?"</div><div><br></div><div>Or something like that and see who responds and what they say. :)</div><div><br></div><div>Thoughts?</div><div><br></div><div>-eric</div></div></div></div>