| 7f5c8f97 | 17-Mar-2012 |
John Marino <draco@marino.st> |
rtld: Add main object initialization and finalization
Since DragonFly's inception, crt1 has called _init and _fini functions of the binary rather than leaving this task to the runtime linker. Likel
rtld: Add main object initialization and finalization
Since DragonFly's inception, crt1 has called _init and _fini functions of the binary rather than leaving this task to the runtime linker. Likely this was done in order to use the same crt code for both statically and dynamically linked binaries.
When FreeBSD imported DragonFly's preinit, init, and fini array handling code, they moved the _init and _fini calls to rtld. In order for rtld to maintain compatiblity with binaries created with crt code that call these functions, rtld looks for an ELF note that indicates the binary was built with a crt that does not call _init and _fini.
This commit imports this capability as well as synchronizes some of the changes FreeBSD made to the DragonFly code. Many of the differences weren't necessary, but some represented improvements. In any case, it benefits both operating systems to minimize the differences between the runtime linkers in order to continue to collaborate and share new features.
Taken from: FreeBSD SVN 232831 (2012-03-11)
One key difference between the DragonFly and FreeBSD implementations is that FreeBSD will not properly execute a binary that requires initialization and/or finalization if the PT_NOTE program header is intentionally omitted using a custom linker script and the PHDRS directive. In the same case, DragonFly will look to see if the main binary contains a gnu hash dynamic tag. If it does, it assumes the binary was built with the new crt, which is a very good assumption. Since gnu hash was inserted by default into binaries only a week ago, there's only a window of few days where this isn't true, and PT_NOTE-free binaries are very rare.
show more ...
|
| 0e63a289 | 21-Jan-2012 |
John Marino <draco@marino.st> |
rtld: Add STT_GNU_IFUNC and R_MACHINE_IRELATIVE_GNU support
Add support for STT_GNU_IFUNC and R_MACHINE_IRELATIVE GNU extensions to rtld. This adds runtime bits neccessary for the use of the dispatc
rtld: Add STT_GNU_IFUNC and R_MACHINE_IRELATIVE_GNU support
Add support for STT_GNU_IFUNC and R_MACHINE_IRELATIVE GNU extensions to rtld. This adds runtime bits neccessary for the use of the dispatch functions from the dynamically-linked executables and shared libraries.
To allow use of external references from the dispatch function, resolution of the R_MACHINE_IRESOLVE relocations in PLT is postponed until GOT entries for PLT are prepared, and normal resolution of the GOT entries is finished. Similar to how it is done by GNU, IRELATIVE relocations are resolved in advance, instead of normal lazy handling for PLT.
Taken-from: FreeBSD SVN 228435 (12 DEC 2011) FreeBSD SVN 228503 (14 DEC 2011) FreeBSD SVN 229508 (04 JAN 2012)
show more ...
|
| e9de6dcc | 21-Jan-2012 |
John Marino <draco@marino.st> |
rtld: Add stubs to support PT_GNU_STACK
This functionality requires kernel support to determine the initial stack access mode. This is how it's supposed to work:
If the loaded DSO requires an exec
rtld: Add stubs to support PT_GNU_STACK
This functionality requires kernel support to determine the initial stack access mode. This is how it's supposed to work:
If the loaded DSO requires an executable stack as specified by the PF_X bit or p_flags on PT_GNU_STACK phdr, yet the current stack protection does not permit execution: The map_stacks_exec function should change the stack protection mode of all thread stacks.
The PT_GNU_STACK phdr parser has been implemented as well as a private interface to _rtld_get_stack_prot() in order to export the stack access mode calculated by rtld.
Left to do: 1) Implement stack protection in the kernel 2) Add PT_GNU_STACK functionality in the kernel 3) Add a method to change stack protection mode in libc or libthread 4) Implement map_stacks_exec function in rtld.
show more ...
|
| 1c2e3f3c | 14-Jan-2012 |
John Marino <draco@marino.st> |
rtld: remove broken functionality to build exec. version
If anyone had tried to build an executable version of the dynamic linker using the source makefiles, it would have failed. The i386 version
rtld: remove broken functionality to build exec. version
If anyone had tried to build an executable version of the dynamic linker using the source makefiles, it would have failed. The i386 version had bad CFLAGS and the x86_64 was missing the ldscript. Moreever, as the gold linker doesn't use ldscripts, it was GNU linker (ld.bfd) specific.
If somebody decides this functionality is still desired, the ldscript files from FreeBSD (elf_rtld.x) can be imported from FreeBSD likely without modification. The now-dummy makefiles were alterated with similar comments.
show more ...
|