History log of /freebsd-10-stable/libexec/rtld-elf/rtld.c
Revision Date Author Comments
# 331206 19-Mar-2018 marius

MFC: r328834

o Let rtld(1) set up psABI user trap handlers prior to executing the
objects' init functions instead of doing the setup via a constructor
in libc as the init functions may already depend on these handlers
to be in place. This gets us rid of:
- the undefined order in which libc constructors as __guard_setup()
and jemalloc_constructor() are executed WRT __sparc_utrap_setup(),
- the requirement to link libc last so __sparc_utrap_setup() gets
called prior to constructors in other libraries (see r122883).
For static binaries, crt1.o still sets up the user trap handlers.
o Move misplaced prototypes for MD functions in to the MD prototype
section of rtld.h.
o Sprinkle nitems().


# 323877 21-Sep-2017 jhb

MFC 323025: Read max_stack_flags from correct object.

'obj' is not initialized here.

Sponsored by: DARPA / AFRL


# 320888 11-Jul-2017 kib

MFC r320658:
When reporting undefined symbol, note the version, if specified.


# 314199 24-Feb-2017 kib

MFC r313494:
Handle protected symbols in rtld.


# 312700 24-Jan-2017 bdrewery

MFC r310025:

Take write lock for rtld_bind before modifying obj_list in dl_iterate_phdr().


# 312402 19-Jan-2017 kib

MFC r311984:
For the main binary, postpone enforcing relro read-only protection
until copy relocations are done.


# 310238 18-Dec-2016 kib

MFC r310155:
Fix typo.


# 309371 01-Dec-2016 jhb

MFC 308456: Pass the correct flag to find_symdef() from _rtld_bind().

When symbol versioning was added to rtld, the boolean 'in_plt' argument
to find_symdef() was converted to a bitmask of flags. The first flag
added was 'SYMLOOK_IN_PLT' which replaced the 'in_plt' bool. This
happened to still work by accident as SYMLOOK_IN_PLT had the value of 1
which is the same as 'true', so there should be no functional change.


# 309061 23-Nov-2016 kib

MFC r308689:
Pass CPUID[1] %edx (cpu_feature), %ecx (cpu_feature2) and
CPUID[7].%ebx (cpu_stdext_feature), %ecx (cpu_stdext_feature2) to the
ifunc resolvers on x86.

MFC r308925:
Adjust r308689 to make rtld compilable with either in-tree or
(hopefully) stock gcc 4.2.1 on i386 and other arches.


# 304455 19-Aug-2016 kib

MFC r304012:
Fill phdr and phsize for rtld object.


# 304454 19-Aug-2016 kib

MFC r304011:
Remove all remaining uses of TAILQ_FOREACH_FROM() from rtld-elf.


# 303169 21-Jul-2016 bdrewery

MFC r302908:

Fix dlsym(RTLD_NEXT) handling to only return the next library in last library
cases.


# 301581 08-Jun-2016 kib

MFC r300691:
Fix issues found by Coverity in the rtld-elf.c:gethints().


# 296939 16-Mar-2016 kib

MFC r296319:
Fix handling of DT_TEXTREL for an object with more than one read-only
segment.

PR: 207631


# 296727 12-Mar-2016 kib

MFC r257811 (by markj):
Include rtld itself when iterating over loaded ELF objects in
dl_iterate_phdr(3).

MFC r294373:
Do not call callbacks for dl_iterate_phdr(3) with the rtld bind and
phdr locks locked.

MFC r294470 (by kan):
Fix initlist_add_object invocation parameters.

MFC r294936 (by kan):
Do not unlock rtld_phdr_lock over callback invocations.


# 293317 07-Jan-2016 emaste

MFC r292705: rtld: remove old XXX comment missed in r35529


# 287560 08-Sep-2015 andrew

MFC r287369:
Ensure we use calculate_first_tls_offset, even if the main program doesn't
have TLS program header. This is needed on architectures with Variant I
tls, that is arm, arm64, mips, and powerpc. These place the thread control
block at the start of the buffer and, without this, this data may be
trashed.

This appears to not be an issue on mips or powerpc as they include a second
adjustment to move the thread local data, however this is on arm64 (with a
future change to fix placing this data), and should be on arm. I am unable
to trigger this on arm, even after changing the code to move the data
around to make it more likely to be hit. This is most likely because my
tests didn't use the variable in offset 0.

Reviewed by: kib
MFC after: 1 week
Sponsored by: ABT Systems Ltd


# 287331 31-Aug-2015 emaste

MFC r282551: Remove historical GNUC test

The requirement is for a GCC-compatible compiler and not necessarily
GCC itself. However, we currently expect any compiler used for building
the whole of FreeBSD to be GCC-compatible and many things will break if
not; there's no longer a need to have an explicit test for this in rtld.


# 284954 30-Jun-2015 des

MFH (r277695): allow tracing dlfunc() / dlsym() events


# 282412 04-May-2015 kib

MFC r282109:
Always do token substitution, do not require -z origin to do it.


# 282118 27-Apr-2015 emaste

MFC r281005: Make die available as rtld_die for use by MD relocation code

Sponsored by: The FreeBSD Foundation


# 281849 22-Apr-2015 kib

MFC r281549:
Implement support for -z global linker option.


# 281486 13-Apr-2015 peter

MFC r268182: Initialize page sizes early for ia64.


# 281453 12-Apr-2015 kib

MFC r280816:
Change default visibility for rtld to hidden, on x86.


# 281452 12-Apr-2015 kib

MFC r264346 (by alc):
Pass MAP_ALIGNED_SUPER to allocate the whole dso region if its text is large
enough for the superpage mapping.


# 279713 06-Mar-2015 jkim

MFC: r279364

Use realpath(3) to properly expand $ORIGIN to its absolute path.


# 279218 23-Feb-2015 jhb

MFC 275412:
The runtime linker needs to include a path to itself in the link map
it exports to the debugger. It currently has two choices: it can use
a compiled-in path (/libexec/ld-elf.so.1) or it can use the path stored
in the interpreter path in the binary being executed. The runtime linker
currently prefers the second. However, this is usually wrong for compat32
binaries since the binary specifies the path of rtld on a 32-bit system
(/libexec/ld-elf.so.1) instead of the actual path (/libexec/ld-elf32.so.1).
For now, always assume the compiled in path (/libexec/ld-elf32.so.1) as
the rtld path and ignore the path in the binary for the 32-bit runtime
linker.


# 278309 06-Feb-2015 kib

MFC r277936:
Use powerof2(). Remove single-use variable.


# 276908 10-Jan-2015 kib

MFC r276627:
Add rtld private interface for dso to detect dynamic loading
vs. static linking.


# 274531 14-Nov-2014 emaste

Always return pathname in dl_iterate_phdr's dlpi_name, as Linux does

Linux LD_ITERATE_PHDR(3):
The dlpi_name field is a null-terminated string giving the
pathname from which the shared object was loaded.

That functionality is much more useful than returning just the short
name.

Update dl_iterate_phdr(3) to follow r272842

MFC of r272842 and r272848


# 271469 12-Sep-2014 kib

MFC r270798:
Process STT_GNU_IFUNC when doing non-plt relocations.

MFC r270802:
Only do the second pass over non-plt relocations when the first pass
found IFUNCs.

Approved by: re (gjb)


# 269680 07-Aug-2014 markj

MFC r265456, r265578:
Add a postinit debugger hook to rtld. This will be used by dtrace(1) to halt
the victim process before its entry point is called, at which point probes
and DOF data are registered with the kernel. The r_debug_state hook cannot
be used for this purpose, as it is called before the program's init routines
are invoked and in particular before DOF data is registered (via drti.o).


# 259292 13-Dec-2013 kib

MFC r259044:
For variant II static TLS, properly align tls segments.

MFC r259072:
Cast Elf_Addr to void * to match the free_aligned() argument type.


# 287560 08-Sep-2015 andrew

MFC r287369:
Ensure we use calculate_first_tls_offset, even if the main program doesn't
have TLS program header. This is needed on architectures with Variant I
tls, that is arm, arm64, mips, and powerpc. These place the thread control
block at the start of the buffer and, without this, this data may be
trashed.

This appears to not be an issue on mips or powerpc as they include a second
adjustment to move the thread local data, however this is on arm64 (with a
future change to fix placing this data), and should be on arm. I am unable
to trigger this on arm, even after changing the code to move the data
around to make it more likely to be hit. This is most likely because my
tests didn't use the variable in offset 0.

Reviewed by: kib
MFC after: 1 week
Sponsored by: ABT Systems Ltd


# 287331 31-Aug-2015 emaste

MFC r282551: Remove historical GNUC test

The requirement is for a GCC-compatible compiler and not necessarily
GCC itself. However, we currently expect any compiler used for building
the whole of FreeBSD to be GCC-compatible and many things will break if
not; there's no longer a need to have an explicit test for this in rtld.


# 284954 30-Jun-2015 des

MFH (r277695): allow tracing dlfunc() / dlsym() events


# 282412 04-May-2015 kib

MFC r282109:
Always do token substitution, do not require -z origin to do it.


# 282118 27-Apr-2015 emaste

MFC r281005: Make die available as rtld_die for use by MD relocation code

Sponsored by: The FreeBSD Foundation


# 281849 22-Apr-2015 kib

MFC r281549:
Implement support for -z global linker option.


# 281486 13-Apr-2015 peter

MFC r268182: Initialize page sizes early for ia64.


# 281453 12-Apr-2015 kib

MFC r280816:
Change default visibility for rtld to hidden, on x86.


# 281452 12-Apr-2015 kib

MFC r264346 (by alc):
Pass MAP_ALIGNED_SUPER to allocate the whole dso region if its text is large
enough for the superpage mapping.


# 279713 06-Mar-2015 jkim

MFC: r279364

Use realpath(3) to properly expand $ORIGIN to its absolute path.


# 279218 23-Feb-2015 jhb

MFC 275412:
The runtime linker needs to include a path to itself in the link map
it exports to the debugger. It currently has two choices: it can use
a compiled-in path (/libexec/ld-elf.so.1) or it can use the path stored
in the interpreter path in the binary being executed. The runtime linker
currently prefers the second. However, this is usually wrong for compat32
binaries since the binary specifies the path of rtld on a 32-bit system
(/libexec/ld-elf.so.1) instead of the actual path (/libexec/ld-elf32.so.1).
For now, always assume the compiled in path (/libexec/ld-elf32.so.1) as
the rtld path and ignore the path in the binary for the 32-bit runtime
linker.


# 278309 06-Feb-2015 kib

MFC r277936:
Use powerof2(). Remove single-use variable.


# 276908 10-Jan-2015 kib

MFC r276627:
Add rtld private interface for dso to detect dynamic loading
vs. static linking.


# 274531 14-Nov-2014 emaste

Always return pathname in dl_iterate_phdr's dlpi_name, as Linux does

Linux LD_ITERATE_PHDR(3):
The dlpi_name field is a null-terminated string giving the
pathname from which the shared object was loaded.

That functionality is much more useful than returning just the short
name.

Update dl_iterate_phdr(3) to follow r272842

MFC of r272842 and r272848


# 271469 12-Sep-2014 kib

MFC r270798:
Process STT_GNU_IFUNC when doing non-plt relocations.

MFC r270802:
Only do the second pass over non-plt relocations when the first pass
found IFUNCs.

Approved by: re (gjb)


# 269680 07-Aug-2014 markj

MFC r265456, r265578:
Add a postinit debugger hook to rtld. This will be used by dtrace(1) to halt
the victim process before its entry point is called, at which point probes
and DOF data are registered with the kernel. The r_debug_state hook cannot
be used for this purpose, as it is called before the program's init routines
are invoked and in particular before DOF data is registered (via drti.o).


# 259292 13-Dec-2013 kib

MFC r259044:
For variant II static TLS, properly align tls segments.

MFC r259072:
Cast Elf_Addr to void * to match the free_aligned() argument type.