objcopy behavior for --globalize-symbol and --keep-global-symbol (-G)
Jordan Rupprecht via binutils
binutils@sourceware.org
Mon Sep 24 22:25:00 GMT 2018
More information about the Binutils mailing list
Mon Sep 24 22:25:00 GMT 2018
- Previous message (by thread): objcopy behavior for --globalize-symbol and --keep-global-symbol (-G)
- Next message (by thread): [CFP] Springer- LNEE : 3rd International Symposium of Information and Internet Technology | 20 - 22 November 2018 Bandung, Indonesia, Submission Deadline 30th September 2018!!!
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Mon, Sep 17, 2018 at 7:56 AM Nick Clifton <nickc@redhat.com> wrote: > > Hi Jordan, > > > As part of work on LLVM binutils, I've been spending time looking at > > GNU objcopy. One thing I'm confused by is how --globalize-symbol and > > --keep-global-symbol are supposed to work, especially when comparing > > their documented effects vs reading the code. > > To be fair, this code was never planned out fully, rather it grew organically... All good software is :) > > > * Weak symbols are not globalized. --help/man pages never mention > > this. Is this intentional? > > Yes. There is no such thing as a weak local symbol. (Well there shouldn't > be anyway). So when promoting from LOCAL to GLOBAL there is no need to also > check for WEAK. > Technically a weak symbol isn't global either though -- i.e. the binding type is an enum of STB_LOCAL/STB_GLOBAL/STB_WEAK (plus enum masks). Still, I'm not sure why anyone would want to take a weak symbol and make it global. Maybe someone would want to take an object file with a weak symbol and make sure it's a link error to also include some other object file that has that symbol as global? Anyway, it's purely hypothetical. > > > * Supposing we had an object file with two globals, SomeGlobal and > > SomeOtherGlobal, 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. 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. > > All true. > > > Although this is > > a weird edge case, should this be changed so that --keep-global-symbol > > implicitly keeps anything also specified via --globalize-symbol? (The > > code seems technically correct with respect to the documentation, but > > IMO the behavior is counter-intuitive). > > Actually I think that it should be an error to mix the two options. > However you code it, somebody is going to get confused about the behaviour > when both options are specified. Best to keep things simple and consider > the two options to be mutually exclusive. Agree, probably worth just making it an error (or at least a warning) to use both flags. > > Cheers > Nick > Thanks! -- Jordan -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 4849 bytes Desc: S/MIME Cryptographic Signature URL: <https://sourceware.org/pipermail/binutils/attachments/20180924/28b684a2/attachment.p7s>
- Previous message (by thread): objcopy behavior for --globalize-symbol and --keep-global-symbol (-G)
- Next message (by thread): [CFP] Springer- LNEE : 3rd International Symposium of Information and Internet Technology | 20 - 22 November 2018 Bandung, Indonesia, Submission Deadline 30th September 2018!!!
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Binutils mailing list