[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH RFC] x86/lld: fix symbol map generation
On 05.05.2022 10:39, Roger Pau Monné wrote: > On Tue, May 03, 2022 at 10:17:44AM +0200, Jan Beulich wrote: >> On 02.05.2022 17:20, Roger Pau Monne wrote: >>> The symbol map generation (and thus the debug info attached to Xen) is >>> partially broken when using LLVM LD. That's due to LLD converting >>> almost all symbols from global to local in the last linking step, and >> >> I'm puzzled by "almost" - is there a pattern of which ones aren't >> converted? >> >> Also "last linking step" is ambiguous, as we link three binaries and >> aiui the issue is present on every of these passes. May I suggest >> "... when linking actual executables" or (still somewhat ambiguous) >> "... when linking final binaries"? >> >>> thus confusing tools/symbols into adding a file prefix to all text >>> symbols, the results looks like: >>> >>> Xen call trace: >>> [<ffff82d040449fe8>] R xxhash64.c#__start_xen+0x3938/0x39c0 >>> [<ffff82d040203734>] F __high_start+0x94/0xa0 >>> >>> In order to workaround this create a list of global symbols prior to >>> the linking step, and use objcopy to convert the symbols in the final >>> binary back to global before processing with tools/symbols. >>> >>> Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx> >>> --- >>> I haven't found a way to prevent LLD from converting the symbols, so >>> I've come up with this rather crappy workaround. >> >> Perhaps a map file (like we use for shared libraries in tools/) would >> allow doing so? But of course this would want to be machine-generated, >> not manually maintained. >> >> Have you gained any insight into _why_ they are doing what they do? > > So after raising this in the LLVM LD forum, I was told this behavior > is due to the spec: > > "A hidden symbol contained in a relocatable object must be either > removed or converted to STB_LOCAL binding by the link-editor when the > relocatable object is included in an executable file or shared > object." > > Then I did some search myself and found that you raised the same with > GNU ld not doing the conversion: > > https://sourceware.org/bugzilla/show_bug.cgi?id=12374 Hmm, interesting. Too long ago to remember, but yes. > So it seems LLVM LD goes a bit further than GNU ld and also changes > the binding of symbols in the .symtab. I'm not sure I would consider > the behavior of either linkers wrong. I agree (taking into account Alan's comment in the bug report above). > As a test I've attempted to disable the hidden visibility setting we > set in compiler.h, just to realize that parts of our code do rely on > having hidden visibility. That's the bug and alternative constructs > that use the "i" asm constrain with function pointers. That's only > possible in the absence of a GOT or PLT table: > > https://godbolt.org/z/jK3bq4fhe Right, -fpic would then also need to go away. > So I think the way to fix this would be to set the visibility to > protected instead of hidden, Originally, when we introduced the use of hidden, it was pretty clear that protected would suffice, but using hidden seemed more logical. Now that we have a reason where hidden ends up being too strict, I agree we can switch to protected. > and then to also make the setting of the > visibility unconditional: the compiler not supporting -fvisibility and > Xen not setting it will just lead to compiler errors further on during > the build process. I guess this being conditional pre-dates our requiring of gcc 4.1, as that version looks to support both the command line option and the pragma we use. So switching to making this unconditional ought to be fine. Jan
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |