From c6063d0da8e1f8d8452b0c2ee1c7ad718c1a7052 Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Tue, 6 May 2014 04:22:01 +0000 Subject: Use src.opts.mk in preference to bsd.own.mk except where we need stuff from the latter. --- libexec/Makefile | 2 +- libexec/atf/atf-check/Makefile | 1 + libexec/ftpd/Makefile | 2 +- libexec/rlogind/Makefile | 2 +- libexec/rtld-elf/Makefile | 2 +- libexec/tcpd/Makefile | 2 +- libexec/telnetd/Makefile | 2 +- 7 files changed, 7 insertions(+), 6 deletions(-) (limited to 'libexec') diff --git a/libexec/Makefile b/libexec/Makefile index e087a8a8ffe7..8a32694d4050 100644 --- a/libexec/Makefile +++ b/libexec/Makefile @@ -1,7 +1,7 @@ # @(#)Makefile 8.1 (Berkeley) 6/4/93 # $FreeBSD$ -.include +.include SUBDIR= ${_atf} \ ${_atrun} \ diff --git a/libexec/atf/atf-check/Makefile b/libexec/atf/atf-check/Makefile index 0cfa8636491b..093de06ed534 100644 --- a/libexec/atf/atf-check/Makefile +++ b/libexec/atf/atf-check/Makefile @@ -25,6 +25,7 @@ # # $FreeBSD$ +.include .include ATF= ${.CURDIR:H:H:H}/contrib/atf diff --git a/libexec/ftpd/Makefile b/libexec/ftpd/Makefile index e415407fb9e6..0c7c9826a843 100644 --- a/libexec/ftpd/Makefile +++ b/libexec/ftpd/Makefile @@ -1,7 +1,7 @@ # @(#)Makefile 8.2 (Berkeley) 4/4/94 # $FreeBSD$ -.include +.include PROG= ftpd MAN= ftpd.8 ftpchroot.5 diff --git a/libexec/rlogind/Makefile b/libexec/rlogind/Makefile index 9807dc8e5ba3..de0fb20e2961 100644 --- a/libexec/rlogind/Makefile +++ b/libexec/rlogind/Makefile @@ -1,7 +1,7 @@ # @(#)Makefile 8.1 (Berkeley) 6/4/93 # $FreeBSD$ -.include +.include PROG= rlogind MAN= rlogind.8 diff --git a/libexec/rtld-elf/Makefile b/libexec/rtld-elf/Makefile index 2a0953c96dfa..21e2219d3727 100644 --- a/libexec/rtld-elf/Makefile +++ b/libexec/rtld-elf/Makefile @@ -1,6 +1,6 @@ # $FreeBSD$ -.include +.include MK_SSP= no PROG?= ld-elf.so.1 diff --git a/libexec/tcpd/Makefile b/libexec/tcpd/Makefile index e707a4e334e8..f3fbf29b5d5f 100644 --- a/libexec/tcpd/Makefile +++ b/libexec/tcpd/Makefile @@ -1,6 +1,6 @@ # $FreeBSD$ -.include +.include .PATH: ${.CURDIR}/../../contrib/tcp_wrappers diff --git a/libexec/telnetd/Makefile b/libexec/telnetd/Makefile index dcc339878e14..99f023f263f2 100644 --- a/libexec/telnetd/Makefile +++ b/libexec/telnetd/Makefile @@ -3,7 +3,7 @@ # Do not define -DKLUDGELINEMODE, as it does not interact well with many # telnet implementations. -.include +.include TELNETDIR= ${.CURDIR}/../../contrib/telnet .PATH: ${TELNETDIR}/telnetd -- cgit v1.3 From a8509eb20e4f11f0813f6c3262264b98f8dfb8a2 Mon Sep 17 00:00:00 2001 From: Mark Johnston Date: Tue, 6 May 2014 18:07:58 +0000 Subject: 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). Reviewed by: kib MFC after: 2 weeks --- libexec/rtld-elf/Symbol.map | 1 + libexec/rtld-elf/rtld.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+) (limited to 'libexec') diff --git a/libexec/rtld-elf/Symbol.map b/libexec/rtld-elf/Symbol.map index 9ad6251848bc..e82b1d45297d 100644 --- a/libexec/rtld-elf/Symbol.map +++ b/libexec/rtld-elf/Symbol.map @@ -30,4 +30,5 @@ FBSDprivate_1.0 { _rtld_atfork_post; _rtld_addr_phdr; _rtld_get_stack_prot; + _rtld_debug_postinit; }; diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index f96b8e7189f7..72b312f337b9 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -162,6 +162,7 @@ static bool matched_symbol(SymLook *, const Obj_Entry *, Sym_Match_Result *, const unsigned long); void r_debug_state(struct r_debug *, struct link_map *) __noinline; +void _r_debug_postinit(struct link_map *) __noinline; /* * Data declarations. @@ -637,6 +638,7 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp) if (obj_main->crt_no_init) preinit_main(); objlist_call_init(&initlist, &lockstate); + _r_debug_postinit(&obj_main->linkmap); objlist_clear(&initlist); dbg("loading filtees"); for (obj = obj_list->next; obj != NULL; obj = obj->next) { @@ -3552,6 +3554,19 @@ r_debug_state(struct r_debug* rd, struct link_map *m) __asm __volatile("" : : : "memory"); } +/* + * A function called after init routines have completed. This can be used to + * break before a program's entry routine is called, and can be used when + * main is not available in the symbol table. + */ +void +_r_debug_postinit(struct link_map *m) +{ + + /* See r_debug_state(). */ + __asm __volatile("" : : : "memory"); +} + /* * Get address of the pointer variable in the main program. * Prefer non-weak symbol over the weak one. -- cgit v1.3 From 7a61fc5a8eaa79ad84d8844ca26cead31b62fb29 Mon Sep 17 00:00:00 2001 From: Mark Johnston Date: Wed, 7 May 2014 17:21:22 +0000 Subject: - Export the function added in r265456 rather than the non-existent _rtld_debug_postinit(). [1] - Use __compiler_membar() instead of inline asm in _r_debug_state() and _r_debug_postinit(). [2] Pointy hat to: markj [1] Reported by: attilio [2] Discussed with: kib X-MFC-With: r265456 --- libexec/rtld-elf/Symbol.map | 2 +- libexec/rtld-elf/rtld.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'libexec') diff --git a/libexec/rtld-elf/Symbol.map b/libexec/rtld-elf/Symbol.map index e82b1d45297d..5ea7d7e171f6 100644 --- a/libexec/rtld-elf/Symbol.map +++ b/libexec/rtld-elf/Symbol.map @@ -30,5 +30,5 @@ FBSDprivate_1.0 { _rtld_atfork_post; _rtld_addr_phdr; _rtld_get_stack_prot; - _rtld_debug_postinit; + _r_debug_postinit; }; diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index 72b312f337b9..443767d99ba4 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -3551,7 +3551,7 @@ r_debug_state(struct r_debug* rd, struct link_map *m) * even when marked __noinline. However, gdb depends on those * calls being made. */ - __asm __volatile("" : : : "memory"); + __compiler_membar(); } /* @@ -3564,7 +3564,7 @@ _r_debug_postinit(struct link_map *m) { /* See r_debug_state(). */ - __asm __volatile("" : : : "memory"); + __compiler_membar(); } /* -- cgit v1.3