This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Create a hook for inspecting program headers during library load


New MIPS ABI extensions include additional ABI related information which is
made available via a processor specific program header/segment. The segment
contains detailed information about ABI extensions and it is necessary to 
inspect this to decide whether or not to load a given library.

A loadable segment containing a simple versioned structure is MIPS answer
to a frequently discussed idea of making attribute information visible to
the dynamic linker (without the complexity of the attribute section's
encoding).

The proposed hook looks like this:

/* Return nonzero iff ELF program headers are compatible with the running
   host.  */

static inline bool
elf_machine_phdr_check (const ElfW(Phdr) *phdr, ElfW(Half) phnum,
				   const char *buf, ssize_t len, int fd,
				   struct link_map *map)
{
  return true;
}

The hook is passed:
* The program headers for the candidate library
* The buffer holding the first part of the ELF.  It is expected that
  any segment which needs reading will generally follow the program
  headers so will often be included in the preloaded part of the ELF.
* The file handle to read any part of the ELF.
* The overall link map.  This enables inspection of any libraries which
  are already loaded.

This patch introduces the hook and adds stub implementations to all
ports.

Does this prototype seem acceptable?

Does the addition of the stub implementation to the generic architecture
qualify as documentation, I can't see anywhere else like a 'new port'
guide to update?

What sort of testing is needed to commit this (I have only done
x86_64-linux-gnu and mips*-linux-gnu)?

I am happy to put the outcome of this thread on the wiki. Please could
you add me as an editor (MatthewFortune)?

Thanks,
Matthew

	* elf/dl-load.c (open_verify): Add hook for phdr check.
	* sysdeps/aarch64/dl-machine.h (elf_machine_phdr_check): New static
	function.
	* sysdeps/alpha/dl-machine.h: Likewise.
	* sysdeps/arm/dl-machine.h: Likewise.
	* sysdeps/generic/dl-machine.h: Likewise.
	* sysdeps/hppa/dl-machine.h: Likewise.
	* sysdeps/i386/dl-machine.h: Likewise.
	* sysdeps/ia64/dl-machine.h: Likewise.
	* sysdeps/m68k/dl-machine.h: Likewise.
	* sysdeps/microblaze/dl-machine.h: Likewise.
	* sysdeps/mips/dl-machine.h: Likewise.
	* sysdeps/powerpc/powerpc32/dl-machine.h: Likewise.
	* sysdeps/powerpc/powerpc64/dl-machine.h: Likewise.
	* sysdeps/s390/s390-32/dl-machine.h: Likewise.
	* sysdeps/s390/s390-64/dl-machine.h: Likewise.
	* sysdeps/sh/dl-machine.h: Likewise.
	* sysdeps/sparc/sparc32/dl-machine.h: Likewise.
	* sysdeps/sparc/sparc64/dl-machine.h: Likewise.
	* sysdeps/tile/dl-machine.h: Likewise.
	* sysdeps/x86_64/dl-machine.h: Likewise.

Attachment: 0002-Add-a-hook-to-enable-load-time-inspection-of-program.patch
Description: 0002-Add-a-hook-to-enable-load-time-inspection-of-program.patch


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]