[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RFC: Add a .note.gnu.property section



There are cases where linker and run-time loader need more information
about ELF objects beyond what the current gABI provides:

1. Minimum ISAs.  Executables and shared objects, which are optimized
specifically to run on a particular processor, will not run on processors
which don't support the same set of ISAs.  Since x86 only has EM_IAMCU,
EM_386 and EM_X86_64 ELF machine codes, run-time loader needs additional
information to tell if an executable or a shared object is compatible
with available ISAs.
2. Stack size.  Compilers may generate binaries which require larger stack
size than normal.  If run-time loader can query the stack size required
by executable or shared object, it can increase stack size as needed.
3. Additional linking command line options embedded in relocatable object
files:
   a. Additional libraries should be linked in when creating executable
      or shared object.
      http://sourceware.org/bugzilla/show_bug.cgi?id=12485
   b. Additional compiler command line options are needed to properly
      link LTO objects.
      https://gcc.gnu.org/bugzilla/show_bug.cgi?id=41756
      https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47785
      https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54231
      https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53777
4. Relocatable object files compiled against header files from a specific
version of a library must be linked with a compatible library when
creating executable or shared object.
5. Copy relocation and protected visibility are fundamentally incompatible.
On on hand, copy relocation is the part of the psABI and is used to
access global data defined in a shared object from the executable.  It
moves the definition of global data, which is defined in a share object,
to the executable at run-time.  On the other hand, protected visibility
indicates that a symbol is defined locally in the shared object at
run-time.  Both can't be true at the same time.  The current solution
is to make protected symbol more or less like normal symbol, which
prevents optimizing local access to protected symbol within the shared
object.

GNU attributes

GNU binutils supports build attribute and run-time platform compatibility
data in relocatable object files.  Issues with GNU attributes:

1. Many architectures, including x86, don't support GNU attributes:
   a. There are some overlaps between GNU attributes and program
   properties.
   b. GNU attributes may be extended to embed additional linking command
   line options in relocatable object files.
2. On x86, linking a relocatable object full of AVX instructions doesn't
always make the resulting executables or shared libraries to require AVX
to run since AVX functions may be called only via GNU_IFUNC at run-time.
Linker can't set minimum ISAs just from ISAs used by input relocatable
objects.
3. There is no program segment for GNU attributes in executables and
shared objects.
4. Most of attributes aren't applicable to run-time loader.
5. The format of GNU attributes isn't optimal for run-time loader.  A
separate string table is used to store string attributes.

I propose to add a .note.gnu.property section.  It is on hjl/property branch at

https://github.com/hjl-tools/linux-abi

The pdf file is at

https://github.com/hjl-tools/linux-abi/wiki/Linux-Extensions-to-gABI

Any comments, feedbacks?

-- 
H.J.