Commit Graph
661 Commits
Author SHA1 Message Date
John Baldwin bb07b1e8a2 MFC 323025: Read max_stack_flags from correct object.
'obj' is not initialized here.

Sponsored by:	DARPA / AFRL
2017-09-21 20:59:36 +00:00
Konstantin Belousov f3c0e0305e MFC r323102:
Add serial comma.
2017-09-04 08:38:34 +00:00
Konstantin Belousov 6a553fae92 MFC r321607:
Allow to specify targets by absolute paths in libmap.conf.

PR:	221032
2017-08-10 09:02:44 +00:00
Konstantin Belousov 8d9583d9ba MFC r320989:
Language improvements.
2017-07-17 06:10:54 +00:00
Konstantin Belousov 8b8192b045 MFC r320658:
When reporting undefined symbol, note the version, if specified.
2017-07-11 05:31:37 +00:00
Xin LI 8c53d8fc91 MFC r320665:
In open_binary_fd: when using buffer size for strl* and snprintf,
always use >= instead of > to avoid truncation.

releng/11.1 candidate.
2017-07-08 04:30:11 +00:00
Konstantin Belousov 4e220eb81d MFC r320318:
Use address space guard to implement inter-segment gap.
2017-07-05 06:32:53 +00:00
Eric van Gyzen ae82dc4983 MFC r318954
rtld: fix warnings about redundant declarations

Fix warnings about redundant declarations in rtld
when libthr in increased to WARNS=6.

Sponsored by:	Dell EMC
2017-06-01 15:12:51 +00:00
Konstantin Belousov c77ad1e707 MFC r319137:
Correct explanation of the dynamic tokens handling.
2017-06-01 00:50:58 +00:00
Konstantin Belousov 01ab5cf862 MFC r319138:
Document direct execution mode for rtld.
2017-06-01 00:48:59 +00:00
Konstantin Belousov ef130b41ed MFC r318446:
Update my copyright, note The FreeBSD Foundation involvement.
2017-05-29 13:25:55 +00:00
Konstantin Belousov 82269739cd MFC direct execution mode for rtld.
MFC r318313:
Make ld-elf.so.1 directly executable.

MFC r318352 (by jonathan):
Rename rtld's parse_libdir to parse_integer.

MFC r318380:
Pretend that there is some security when executing in direct mode.

MFC r318431 (by jonathan):
Allow rtld direct-exec to take a file descriptor.

MFC r318445:
Fix style, add static keyword before static function definition.

MFC r318739:
For ld.so direct execution mode, implement -p option.
2017-05-29 13:24:27 +00:00
Konstantin Belousov c99be7cd4b MFC r318312:
Fix the AT_EXECFD functionality.
2017-05-29 13:18:20 +00:00
Rodney W. Grimes 05c7f8763e MFC r314833
Convert absolute links to relative links.
	Style.Makefile(9) has been ignored to produce minimal diffs.

MFC r314837
	The relative symlink fix causes downstream issues for
	EMC DELL Isilon so revert the relative symlink fix
	pending a better solution.

	Reported by:	ngie

MFC r315091
	Revert r314833 until the problem with INSTALL_RSYMLINKS can be found
	as it appears to break arm release builds.

	PR:		217705
	Reported by:	[email protected]

Approved by:	grehan (mentor)
2017-05-28 00:13:44 +00:00
Konstantin Belousov cfc6357e5a MFC r318256:
Style.
2017-05-20 00:41:12 +00:00
Andrew Turner ec4081b8da MFC r312764:
Pull the R_AARCH64_TLSDESC code out into a common function and use them in
both the plt and non-plt case.

This fixes an issue where libraries built with LLD can fail with
"Unhandled relocation 1031"
2017-04-20 12:48:01 +00:00
Alan Somers 1652be657d MFC r315040
Increase WARNS for rtld-elf tests

ATF tests have a default WARNS of 0, unlike other usermode programs.

Reviewed by:  ngie, julian
MFC after:    3 weeks
Sponsored by: Spectra Logic Corporation
Differential Revision:        https://reviews.freebsd.org/D9933
2017-04-02 02:16:01 +00:00
Konstantin Belousov dce380c798 MFC r315331:
Implement LD_BIND_NOT knob for rtld.

MFC r315337:
Disable LD_BIND_NOT for setugid processes.

MFC r315429 (by jilles):
Document that LD_BIND_NOT is unset for setugid processes.
2017-03-29 11:03:08 +00:00
Konstantin Belousov 43f62c21d8 MFC r309068 (by jhb):
Fix _mips_rtld_bind() to handle ELF filters.
2017-03-29 10:59:46 +00:00
Konstantin Belousov 3e04ff93b3 MFC r314973:
Avoid bind lock recursion.
2017-03-16 15:13:28 +00:00
Konstantin Belousov eb7ef184da MFC r313494:
Handle protected symbols in rtld.
2017-02-23 07:39:01 +00:00
Mark Johnston 3f05fcbafd MFC r310420, r310421, r310422:
Fix races and logic errors around dlclose().
2017-02-03 01:15:31 +00:00
Ed Maste 05be7eb7d4 MFC r312288: rtld: do not rely on a populated GOT on amd64
On rela architectures GNU BFD ld and gold store the relocation addend
in GOT entries (in addition to the relocation's r_addend field).
rtld previously relied on this to access its own _DYNAMIC symbol in
order to apply its own relocations.

However, recording addends in the GOT is not specified by the ABI,
and some versions of LLVM's LLD linker leave the GOT uninitialized on
rela architectures.

BFD ld does not populate the GOT on sparc64, and sparc64 rtld has a
machine-dependent rtld_dynamic_addr() function that returns the
_DYNAMIC address. Use the same approach on amd64, obtaining the %rip-
relative _DYNAMIC address following a suggestion from Rafael Espíndola.

Architectures other than amd64 should be addressed in future work.
2017-01-26 03:05:27 +00:00
Konstantin Belousov 2ff590f28e MFC r311886:
Fix acquisition of nested write compat rtld locks.

PR:	215826
2017-01-24 11:13:41 +00:00
Konstantin Belousov 5411653712 MFC r311984:
For the main binary, postpone enforcing relro read-only protection
until copy relocations are done.
2017-01-19 06:44:27 +00:00
Konstantin Belousov ceaca157fd MFC r311879:
Use ANSI C definitions, update comment.
2017-01-17 10:32:27 +00:00
Bryan Drewery b2252e0a04 MFC r310025:
Take write lock for rtld_bind before modifying obj_list in dl_iterate_phdr().
2017-01-03 23:28:07 +00:00
Bryan Drewery 02c408bb66 MFC r305148:
DIRDEPS_BUILD: Add some missing dirctories to the build.
2017-01-03 22:51:40 +00:00
Ed Maste 5ceedd3ec7 MFC r309411: Retire long-broken/unused static rtld support
rtld-elf has some vestigial support for building as a static executable.
r45501 introduced a partial implementation with a prescient note that it
"might never be enabled." r153515 introduced ELF symbol versioning
support, and removed part of the unused build infrastructure for static
rtld.

GNU ld populates rela relocation addends and GOT entries with the same
values, and rtld's run-time dynamic executable check relied on this.
Alternate toolchains may not populate the GOT entries, which caused
RTLD_IS_DYNAMIC to return false. Simplify rtld by just removing the
unused check.

If we want to restore static rtld support later on we ought to introduce
a build-time #ifdef flag.

PR:		214972
2017-01-03 15:59:39 +00:00
Konstantin Belousov 50a364fa12 MFC r310155:
Fix typo.
2016-12-19 00:26:25 +00:00
John Baldwin 2ef404ba00 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.
2016-12-01 20:36:48 +00:00
Konstantin Belousov b1478acdc1 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.
2016-11-23 09:25:51 +00:00
Konstantin Belousov f74c20d691 MFC r308688:
Assert that there is no unresolved symbols during rtld linking.
2016-11-22 09:37:31 +00:00
Konstantin Belousov 94073e29e5 MFC r308687:
Update hint to utilize user variable.
2016-11-22 09:35:50 +00:00
Konstantin Belousov 5cc794a196 MFC r304016:
Move defines common between rtld and libsysdecode into the header.
2016-08-19 08:00:48 +00:00
Konstantin Belousov a964f6cc4f MFC r304012:
Fill phdr and phsize for rtld object.
2016-08-19 07:59:00 +00:00
Konstantin Belousov 6f5c799413 MFC r304011:
Remove all remaining uses of TAILQ_FOREACH_FROM() from rtld-elf.
2016-08-19 07:57:43 +00:00
Bryan Drewery 90216203de MFC r302908:
Fix dlsym(RTLD_NEXT) handling to only return the next library in last library
  cases.

Approved by:	re (gjb)
2016-07-22 17:24:36 +00:00
Bryan Drewery e7debdcb15 Fix race for incrementally rebuilding VERSION_MAP.
The dependency is needed in PROG_FULL since only the build of PROG_FULL
is using the LDFLAGS and depending on VERSION_MAP.  This was not a problem
with MK_DEBUG_FILES==no since it only builds PROG.

This should probably be using bsd.lib.mk instead [1]

Reported by:	swills, gjb
Reviewed by:	emaste
Noted by:	rgrimes [1]
Sponsored by:	EMC / Isilon Storage Division
Approved by:	re (kib)
2016-07-03 17:28:39 +00:00
Konstantin Belousov 360ba6bc13 Fix issues found by Coverity in the rtld-elf.c:gethints().
Check that the dirlist path string specification does not cause
overflow and is fully contained in the hints file.
Check that the dirlist string is nul-terminated.
Make 'hdr' static variable, so that hdr.dirlistlen is available when
hints cached value is used on next function calls.  Reset hdr.dirlistlen
to zero if error was detected, so that allocations use reasonable size.
Use 'hints', and not 'p' in the body, since p is only initialized on the
first call.

Reported and reviewed by:	truckman (previous version)
Sponsored by:	The FreeBSD Foundation
CIDs:	1006503, 1006504, 1006676, 1008488, 1007263
MFC after:	2 weeks
2016-05-25 18:10:44 +00:00
Enji Cooper 430f7286a5 Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installed
after r298107

Summary of changes:

- Replace all instances of FILES/TESTS with ${PACKAGE}FILES. This ensures that
  namespacing is kept with FILES appropriately, and that this shouldn't need
  to be repeated if the namespace changes -- only the definition of PACKAGE
  needs to be changed
- Allow PACKAGE to be overridden by callers instead of forcing it to always be
  `tests`. In the event we get to the point where things can be split up
  enough in the base system, it would make more sense to group the tests
  with the blocks they're a part of, e.g. byacc with byacc-tests, etc
- Remove PACKAGE definitions where possible, i.e. where FILES wasn't used
  previously.
- Remove unnecessary TESTSPACKAGE definitions; this has been elided into
  bsd.tests.mk
- Remove unnecessary BINDIRs used previously with ${PACKAGE}FILES;
  ${PACKAGE}FILESDIR is now automatically defined in bsd.test.mk.
- Fix installation of files under data/ subdirectories in lib/libc/tests/hash
  and lib/libc/tests/net/getaddrinfo
- Remove unnecessary .include <bsd.own.mk>s (some opportunistic cleanup)

Document the proposed changes in share/examples/tests/tests/... via examples
so it's clear that ${PACKAGES}FILES is the suggested way forward in terms of
replacing FILES. share/mk/bsd.README didn't seem like the appropriate method
of communicating that info.

MFC after: never probably
X-MFC with: r298107
PR: 209114
Relnotes: yes
Tested with: buildworld, installworld, checkworld; buildworld, packageworld
Sponsored by: EMC / Isilon Storage Division
2016-05-04 23:20:53 +00:00
Pedro F. Giffuni ec489d64bb libexec: minor spelling fixes in comments.
No functional change.
2016-05-01 19:39:23 +00:00
Pedro F. Giffuni 260111ffce rtld-elf: use our roundup2() macro when param.h is available. 2016-04-19 20:12:46 +00:00
Pedro F. Giffuni a5d5e8dd7c rtld-elf: use NULL instead of zero for pointers. 2016-04-19 19:03:55 +00:00
Glen Barber d60840138f MFH
Sponsored by:	The FreeBSD Foundation
2016-04-04 23:55:32 +00:00
Bryan Drewery c0f5aeb032 WITHOUT_TOOLCHAIN: Fix build of rtld.
MK_TOOLCHAIN==no disables building and installing of pic archives.
c_pic.a is still needed for rtld though so force it to build in lib/libc
and link directly to the objdir version of it for rtld.

Somehow this has been broken since r148725.

Sponsored by:	EMC / Isilon Storage Division
2016-03-31 17:27:01 +00:00
Glen Barber 7d536dc855 MFH
Sponsored by:	The FreeBSD Foundation
2016-03-10 21:16:01 +00:00
Bryan Drewery 15c433351f DIRDEPS_BUILD: Connect MK_TESTS.
Sponsored by:	EMC / Isilon Storage Division
2016-03-09 22:46:01 +00:00
Glen Barber 42d27ee343 MFH
Sponsored by:	The FreeBSD Foundation
2016-03-02 23:53:08 +00:00
Konstantin Belousov ca8c8dc3eb Fix handling of DT_TEXTREL for an object with more than one read-only
segment.  According to gABI spec, presence of the tag indicates that
dynamic linker must be prepared to handle relocations against any
read-only segment, not only the segment which we, somewhat arbitrary,
declared the text.

For each read-only segment, add write permission before relocs are
processed, and return to the mapping mode requested by the phdr, after
relocs are done.

Reported, tested, and reviewed by:	emaste
PR:	207631
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
2016-03-02 16:36:24 +00:00