Commit Graph

793 Commits

Author SHA1 Message Date
skrll
be1a58855d More PLABELS are required due to TLS stuff. 2011-03-14 08:49:29 +00:00
skrll
d3aab036e1 Handle some TLS relocs. 2011-03-14 08:21:54 +00:00
skrll
92c298c3a1 First cut at mdtls.c for hppa. 2011-03-14 08:20:15 +00:00
joerg
e7a5551d99 Fill in TLS related fields in dl_iterate_phdr if TLS is supported 2011-03-13 21:08:45 +00:00
joerg
854e6cd69f Add TLS support for AMD64, i386 and SH3.
This material is based upon work partially supported by
The NetBSD Foundation under a contract with Joerg Sonnenberger.
2011-03-12 22:54:36 +00:00
matt
130f2d3d4c Add TLS support for PowerPC.
If the port has __lwp_gettcb_fast or __lwp_settcb use them instead of
__lwp_getprivate_fast or lwp_setprivate.
2011-03-12 07:43:53 +00:00
joerg
7197db08bd Add some clarifications 2011-03-10 17:38:30 +00:00
joerg
9c18c3d543 Add source reference for _lwp_makecontext and
__HAVE___LWP_GETPRIVATE_FAST. Fix enumeration.
2011-03-10 17:22:17 +00:00
joerg
de4cf97515 Fix prototype for __tls_get_addr. Add a generic implementation of it
using __tls_get_addr. Update TLS notes.
2011-03-10 14:27:31 +00:00
skrll
ff1072d23a Whitespace. 2011-03-10 12:53:42 +00:00
joerg
aad599979d Add TLS support infrastructure. For dynamic binaries, ld.elf_so exports
_rtld_tls_allocate and _rtld_tls_free. libpthread uses this functions to
setup the thread private area of all new threads. ld.elf_so is
responsible for setting up the private area for the initial thread.
Similar functions are called from _libc_init for static binaries, using
dl_iterate_phdr to access the ELF Program Header.

Add test cases to exercise the different TLS storage models. Test cases
are compiled and installed on all platforms, but are skipped on
platforms not marked for TLS support.

This material is based upon work partially supported by
The NetBSD Foundation under a contract with Joerg Sonnenberger.

It is inspired by the TLS support in FreeBSD by Doug Rabson and the
clean ups of the DragonFly port of the original FreeBSD modifications.
2011-03-09 23:10:05 +00:00
matt
4fee4fe7b3 Don't rely on >32bit math. 2011-03-04 00:40:48 +00:00
pooka
33ee52c7dc make DEBUG compile without RTLD_DEBUG 2011-02-24 10:58:54 +00:00
matt
483a1c95a2 Fix problem with bss-plt objects which a reloc index, not offset.
(secure-plt uses an offset (index*sizeof(rela), bss-plt uses an index)
secure-plt will now take the offset and divide by 12 for an index.
2011-02-10 02:28:20 +00:00
skrll
3770380428 Unbreak gdb by ensuring _rtld_debug_state is in the dynamic symbol table.
mmm 1 line diffs

mmm not breaking backwards compatibility for anything known/unknown or
public/private.
2011-01-25 12:25:43 +00:00
matt
709c8a2f01 Move powerpc gotptr to the end to preserve binary compatibility. 2011-01-16 15:56:37 +00:00
matt
b094d98191 Warn about DT_TEXTRELs 2011-01-16 02:36:05 +00:00
matt
d31dbd7578 Add secure-plt support for powerpc to ld.elf_so. As part of this, we have to
stop calling into the GOT/_DYNAMIC since they are no longer executable.
2011-01-16 01:22:29 +00:00
skrll
f1d73a2c94 Add support for DF_1_BIND_NOW, DF_1_NODELETE and DF_1_NOOPEN marked
objects, and the RTLD_NODELETE and RTLD_NOLOAD flags to dlopen(3).

Mark libpthread as DF_1_NOOPEN and use it to test the functionality.

Somewhat taken from FreeBSD.

Fixes PR 42029.

OK from christos and joerg.
2010-12-24 12:41:42 +00:00
skrll
1f45aab781 Sprinkle some KNF. 2010-12-19 17:26:51 +00:00
skrll
ad7786ec8b Remove unnecessary #ifdef RTLD_DEBUG 2010-12-19 17:17:50 +00:00
wiz
617acddc41 Remove superfluous Pp. 2010-12-17 08:50:26 +00:00
skrll
1ee8ff33ba Remove implementation detail.
Bump date.
2010-12-17 07:04:52 +00:00
joerg
c4120e324e Replace use of errlist with a single concatenated version and an offset
array. This requires less storage and avoids one runtime relocation per
errno value.
2010-12-16 22:52:32 +00:00
joerg
67cc8c0871 Don't use normal environment handling functions from libc, but iterate
once over the array and clean out entries as needed.
2010-12-16 22:47:27 +00:00
skrll
126c589398 s/rdbg/dbg/ in a few places. 2010-12-16 19:59:39 +00:00
skrll
76d5f138f4 Remove incorrect comment. 2010-12-16 19:35:38 +00:00
wiz
fbc697a1ed Note that $ORIGIN kernel support (in kern/kern_exec.c) is currently disabled.
Info from skrll@.
Bump date.
2010-12-16 19:25:41 +00:00
joerg
67e01e0a99 Build ld.elf_so with -fvisibility=hidden. Exploit this for i386/x86_64
to simplify the assembler code.
2010-12-05 00:56:06 +00:00
joerg
91118529e4 ANSIfy 2010-12-03 23:07:49 +00:00
joerg
239c31f883 Add comment about the unusual stack alignment in .rtld_bind_start. 2010-12-03 22:48:25 +00:00
tron
1fbd900608 Don't use internal libc function __findenv(). 2010-11-14 22:09:16 +00:00
christos
acfd35dad9 PR/44010: YAMAMOTO Takashi: sbrk: grow 0xb3ba2000 failed, error = 12"
(due to setenv changes?)
Provide a mini unsetenv that does not allocate/free memory and does not
bother about locking.
2010-10-29 15:08:17 +00:00
skrll
8b916d603d Add cast so that usr.bin/ldd/elf32 builds. 2010-10-16 17:48:12 +00:00
skrll
e6cdac9c4b Implement dl_iterate_phdr.
Somewhat taken from FreeBSD. Manual page from OpenBSD.
2010-10-16 10:27:06 +00:00
skrll
0a77584d8f Revert previous for now. It's part of a larger commit which will arrive
soon.
2010-10-15 15:08:05 +00:00
skrll
a048346afd Be more tolerant to the location of PT_PHDR in the segment list. 2010-10-15 07:22:44 +00:00
christos
45bdf1678c restore binary compatibility for pre-2.0 binaries, requested by skrll and core. 2010-10-10 21:27:16 +00:00
skrll
a108583dc7 Oops. Remove trailing whitespace in previous. 2010-09-30 19:45:24 +00:00
skrll
d965c46816 Improve debug output. 2010-09-30 19:43:11 +00:00
skrll
0e07ba7138 Add the magic branch instruction that is used by GCC's
__canonicalize_funcptr_for_compare() function to fixup relocations in
order to do function pointer comparisons.

From OpenBSD.
2010-09-30 19:32:40 +00:00
skrll
06acf46b03 Introduce a new type Elf_Symindx for use in decoding the symbol hash table
section and allow this type to be overridden.

The ELF specification says it should always be uint32_t (Elf_Word), but
alpha decided to be different (not sure why). Define Elf_Symindx to be
uint64_t on alpha.

Alpha no longer uses non-standard definitions of Elf64_Sword and
Elf64_Word.  Remove the ability to override these types.

Fixes ld.elf_so after Herculean effort from me and martin.
2010-09-30 09:11:18 +00:00
matt
af56990d0c Make the GOT1_MASK 64-bit clean. 2010-09-24 15:20:52 +00:00
skrll
8f77c5159b Comment reformat. 2010-09-24 12:00:10 +00:00
skrll
2c56298dd9 Wrap long line. 2010-09-24 11:59:28 +00:00
skrll
09601c884f Whitespace. 2010-09-24 11:57:11 +00:00
skrll
6229c56fea Wrap long lines
Reformat comments.
2010-09-24 11:41:46 +00:00
joerg
11fdf81f84 Avoid casting from d_val to plttype of different signedness.
Just two booleans for the same purpose.
2010-09-23 13:03:35 +00:00
skrll
07666b6356 Wrap long line. 2010-09-11 11:11:52 +00:00
joerg
6972211664 Stricter matching for _rtld_invalid_paths by ensuring separator.
Use mem* functions instead of str* for strings of known size.
2010-08-07 19:47:34 +00:00
joerg
f40b256f09 Reduce header pollution for mdreloc.c. Make Obj_Entry argument of
_rtld_relocate_nonplt_objects non-const in preparation for TLS support.
2010-08-06 16:33:17 +00:00
mrg
c8cf27943d make sure to look in CFLAGS, COPTS and CPPFLAGS for abi options.
fixes sgimips64 build of n64 ld.elf_so.
2010-07-11 07:43:12 +00:00
mrg
4c92852a80 remove almost all the ability to build netbsd with an a.out target.
we're ELF now, and there are many missing checks against OBJECT_FMT.
if we ever consider switching, the we can figure out what new ones
we need but for now it's just clutter.

this doesn't remove any of the support for exec_aout or any actually
required-for-boot a.out support, only the ability to build a netbsd
release in a.out format.  ie, most of this code has been dead for
over a decade.

i've tested builds on vax, amd64, i386, mac68k, macppc, sparc, atari,
amiga, shark, cats, dreamcast, landisk, mmeye and x68k.  this covers
the 5 MACHINE_ARCH's affected, and all the other arch code touched.
it also includes some actual run-time testing of sparc, i386 and
shark, and i performed binary comparison upon amiga and x68k as well.


some minor details relevant:
- move shlib.[ch] from ld.aout_so into ldconfig proper, and cut them
  down to only the parts ldconfig needs
- remove various unused source files
- switch amiga bootblocks to using elf2bb.h instead of aout2bb.h
2010-07-06 05:59:50 +00:00
joerg
ff0f2fb483 Use fast_remainder32 for the ELF hash. For the hot cache case, this
speeds up Firefox startup by over 2% on AMD64.
Limit hash table buckets to 32bit.
2010-04-05 14:01:26 +00:00
skrll
134b0fcc8f Only apply -Wno-stack-protector where alloca is used. 2010-03-20 16:36:35 +00:00
roy
51085124f6 Use the gcc directive to disable SSP warnings. 2010-03-19 20:53:50 +00:00
roy
d5e8f757b8 Use alloca(3) instead of local xmalloc for creating our DoneLists.
This allows threaded programs to use us a little better, PR lib/43005.
We need to disable SSP when using alloca.
2010-03-18 22:17:55 +00:00
roy
b02ec7e9f8 Implement negative cache checks for symbol lookups.
Uses the Donelist idea from FreeBSD.
2010-02-27 11:16:38 +00:00
skrll
d306de736d Restore backwards compatibility for binaries referencing the main
Obj_Entry.
2010-01-17 08:04:20 +00:00
skrll
2e0bcc8d3b Remove cargo cult dlinfo entry point. 2010-01-16 10:37:51 +00:00
skrll
418048d731 Put the dlopen,and friends entry points back.
They're needed by pre-2.0 binaries. Backward compatibiliity for these
was broken by another commit recently which I'll fix shortly.
2010-01-15 07:07:11 +00:00
skrll
699646b3ea Remove the entry points for dlopen() and friends. They haven't been used
since Aug 2003.
2010-01-14 21:52:07 +00:00
skrll
15b7ff0199 Make DEBUG build compile. 2010-01-14 12:12:07 +00:00
skrll
f88b3d9061 Wrap a few long lines. 2010-01-14 11:58:31 +00:00
skrll
c2796a5929 Shut gcc up. 2010-01-14 11:57:06 +00:00
skrll
8b4b9f3e56 Shut gcc up. 2010-01-13 22:34:07 +00:00
christos
12bd4dbd45 PR/39240: Satoshi Suetake: Don't fail when attempting to resolve weak symbols
when we are doing immediate binding, leave them alone and they will be dealt
with later during lazy binding. From skrll@
2010-01-13 20:17:21 +00:00
skrll
8f7db61734 Reset the COMBRELOC cache Obj_Entry if it was freed.
Fixes PR 41482. Done slightly differently to the patch in the PR.
2010-01-10 07:29:47 +00:00
skrll
fa7832d0b1 Fixup comment. 2010-01-10 06:37:32 +00:00
skrll
09298c1411 Small tidyup. 2010-01-09 15:36:43 +00:00
mrg
249d1f1111 use COPTS for -G0.
replace ${CPUFLAGS:M-mabi=64:M-mabi=o64} with two constructs.
the former doesn't seem to work anymore.
2009-12-18 17:10:07 +00:00
matt
d8d1440d5c Merge from matt-nb5-mips64:
Add N32/N64 support for mips dynamic loader.
2009-12-14 00:41:18 +00:00
mrg
750ad3d59d simplify the logic for compat ld.elf_so and move it here. we now can
find the libc objdir for multiple compat ld.elf_so's, too.
2009-12-13 09:31:47 +00:00
mrg
6af15ae20b if BSD_MK_COMPAT_FILE is defined, .include it. 2009-12-13 09:01:45 +00:00
mrg
f7f0bc40ae rename LD32DIR to MLIBDIR. 2009-12-13 08:25:20 +00:00
christos
1dc0b61eca If the environment is corrupt, die. From FreeBSD. 2009-12-02 15:50:13 +00:00
skrll
77fd7698f3 Make _rtld_pagesz of type size_t.
Fixes round_down for alpha which made ldd(1) break.
2009-11-17 18:44:33 +00:00
skrll
b9fe4e7d17 Add RCSID 2009-11-11 14:15:41 +00:00
skrll
ef99e95537 Fix start symbols for new binutils. 2009-11-04 17:02:43 +00:00
skrll
d43e9fc212 Fix start symbol for newer binutils. 2009-10-22 21:56:13 +00:00
skrll
15653ebb45 ld.elf_so grew more PLABELS with dlinfo so bump HPPA_PLABEL_PRE. 2009-09-25 17:49:56 +00:00
pooka
4c1e54d82b Add Solarisa-like dlinfo() interface to the ELF dynamic linker.
Implement RTLD_DI_LINKMAP which returns a pointer to the linkmap
chain at the given object.  Other Solaris queries are currently
unimplemented.
2009-09-24 21:21:33 +00:00
skrll
ffb28af545 Fix start symbol. I have no idea how this worked before. 2009-09-19 14:54:17 +00:00
skrll
4b849729b2 Fix the start symbol. 2009-09-12 07:22:16 +00:00
jmmv
2cb749c2fd Remove trailing \n in calls to _rtld_error: a newline is automatically
added by a call to the function.
2009-08-29 13:46:54 +00:00
he
45932f91e5 Apply fix borrowed from i386: Fix const issue (cast const pointers
to "const uint8_t *" instead of "caddr_t").
2009-05-24 20:35:41 +00:00
he
237687b934 Copy build fix from i386: Fix const issues (cast const pointers
to "const uint8_t *" instead of "caddr_t").
2009-05-24 18:29:03 +00:00
mjf
27cb8d0e73 After a recent WARNS= bump on ld.elf_so it fails to build on hppa,
complaining that we're "discarding qualifier from pointer target
type".

Use const char * instead of caddr_t to avoid the warning and get
distribution building on hppa again.
2009-05-23 17:50:34 +00:00
martin
c131490c29 Use the new Elf_SOff (signed offset) type to fix a few signed/unsigned
problems.
2009-05-22 21:47:46 +00:00
christos
b19e027aab fix signed/unsigned comparisons and const cast away (untested) 2009-05-20 22:31:46 +00:00
ad
51a76d6f11 Add a reminder about ldd depending on ld.so. 2009-05-20 19:38:38 +00:00
christos
fa64a5bf9b warns=4 2009-05-19 20:44:52 +00:00
lukem
e91bd42f43 Fix const issues (cast const pointers to "const uint8_t *" instead of "caddr_t") 2009-04-12 13:29:29 +00:00
lukem
b4fba76b41 Fix const issues (cast const pointers to "const uint8_t *" instead of "caddr_t")
NOTE: change based on ../i386/mdreloc.c 1.27
XXX: not compile tested
2009-03-16 02:46:47 +00:00
lukem
337930db10 Fix const issues (cast const pointers to "const uint8_t *" instead of "caddr_t") 2009-03-16 02:44:47 +00:00
lukem
500db00274 Default to WARNS=4
Exceptions that need a lower level are:
	getty ld.elf_so lfs_cleanerd makewhatis telnetd tftpd
	hpropd ipropd-master ipropd-slave kadmind kpasswdd
2009-03-16 02:24:55 +00:00
lukem
b8276deac1 rename a variable to avoid a compiler warning 2009-03-15 23:53:03 +00:00
mrg
fb3cc85fef add some (uintptr_t) to some casts, so these compile with ELFSIZE=32
*and _LP64.  necessary for 32/64 bit combo ldd support.
2009-01-06 04:01:46 +00:00
mrg
9108f12f6b move the defines for RTLD_ARCH_SUBDIR into a sub-sub-makefile so we can
grab these values via reach-over more easily.
2009-01-06 02:15:06 +00:00
mrg
8679e33545 if LD32DIR is defined:
- look in src/compat/lib/libc for libc_pic.
- define RTLD_ARCH_SUBDIR to "i386" or "sparc" for amd64 and sparc64
  builds, respectively
if RTLD_ARCH_SUBDIR is defined, add this path before
RTLD_DEFAULT_LIBRARY_PATH in the default search path.
2008-10-26 07:11:54 +00:00