On Fri, 14 Apr 2023 at 16:37, Gerd Hoffmann <kra...@redhat.com> wrote:
>
> On Fri, Apr 14, 2023 at 12:29:21PM +0000, Marvin Häuser wrote:
> > Hi Gerd,
> >
> > Thanks for your effort!
> >
> > Sorry, but I *really* dislike this “BASETOOLS” notion. There might be
> > external tools that also want to use the header (like we do with AUDK)
> > and also edk2 supports host-based unit tests. Imo the macro name
> > should be generic, like “HOST_OS” or “USERLAND” or something (I’m bad
> > with names :) ).
>
> I'm certainly open to better naming ideas.
>
> 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 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


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#103008): https://edk2.groups.io/g/devel/message/103008
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