Hi,

> > Underlying problem is that x64 ProcessorBind.h sets visibility to
> > hidden (anyone knows why?).
> 
> Yes. Toolchains tend to assume that you are generating code for a
> shared library once you enabled -fpic, and this results in lots of
> pointless indirections via the GOT. (This has to do with the
> copy-on-write footprint of shared library pages, as a GOT tends to
> gather all relocated quantities in a small region of memory. It is
> also related to ELF symbol preemption, which is another thing we don't
> give a ^$& about).
> 
> *However*, recent linkers do a better job getting rid of these GOT
> references at link time, once you pass the --relax option. On X64 in
> particular, there are special, relaxable GOTPCREL relocations now that
> will not result in to symbol references via the GOT if the linker
> notices that the symbol in question is never preempted and not
> provided externally.
> 
> So it is worth an experiment whether we still need this to begin with.

Seems to work fine on fedora 37, even without adding --relax, maybe this
is enabled by default (there is a --no-relax switch after all).  I'll go
try older distros / compilers / binutils too.

What would be the failure mode?  Errors on ELF -> PE conversion because
a GOT is present?  Or will things break at runtime?

> >  Seems to be fine for freestanding binaries,
> > but when linking host tools against shared libraries things break.  For
> > some reason on ubuntu only, fedora works fine (both gcc and clang).
> >
> > Automatically detecting freestanding vs. hosted would be even better,
> > anyone knows whenever there is a define which can be used for this?  At
> > least the gcc man page doesn't mention any ...
> 
> ard@gambale:~/linux-build-x86$ gcc -dM -E -o - -xc - <<< ""|grep HOSTED
> #define __STDC_HOSTED__ 1
> ard@gambale:~/linux-build-x86$ gcc -ffreestanding -dM -E -o - -xc -
> <<< ""|grep HOSTED
> #define __STDC_HOSTED__ 0

Nice.  So we have a plan b in case just dropping it doesn't work out.

take care,
  Gerd



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#103160): https://edk2.groups.io/g/devel/message/103160
Mute This Topic: https://groups.io/mt/98257896/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to