Use linker script to make __start/stop_link_set_modules be present

in libs built with binutils >=2.19.  This is a less error-prone
method than the previous where components had to be tagged in the
Makefile as modules (and if they weren't, things broke.  and vice
versa).
This commit is contained in:
pooka 2009-12-12 17:10:19 +00:00
parent f537a9ce5f
commit fbc989bbef
8 changed files with 34 additions and 49 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile.rump,v 1.44 2009/11/27 13:36:30 pooka Exp $
# $NetBSD: Makefile.rump,v 1.45 2009/12/12 17:10:19 pooka Exp $
#
WARNS?= 3 # XXX: src/sys won't compile with -Wsign-compare yet
@ -24,6 +24,7 @@ CPPFLAGS+= -I${RUMPTOP}/../../common/include -I${RUMPTOP}/../arch
CPPFLAGS+= -I${RUMPTOP}/include
CPPFLAGS+= -I${RUMPTOP}/librump/rumpkern/opt
CPPFLAGS+= -nostdinc -I${RUMPTOP}/..
LDFLAGS+= -T ${RUMPTOP}/ldscript.rump
#CPPFLAGS+= -DDEBUG
# kernel libs should not get linked against libc
@ -45,15 +46,6 @@ CPPFLAGS+= -DPPC_OEA
# If this file changes, we need a full rebuild
DPSRCS+= ${RUMPTOP}/Makefile.rump
.ifdef RUMP_ISMODULE
.PATH: ${RUMPTOP}/librump
SRCS+= rump_module.c
.endif
.ifdef RUMP_ISDOMAIN
.PATH: ${RUMPTOP}/librump
SRCS+= rump_domain.c
.endif
#
# Rename library symbols before use. If a symbol does not already belong
# to a rump namespace ("rump" or "RUMP"), prefix it with "rumpns". This

View File

@ -1,7 +1,6 @@
# $NetBSD: Makefile.inc,v 1.13 2009/09/13 22:51:41 pooka Exp $
# $NetBSD: Makefile.inc,v 1.14 2009/12/12 17:10:19 pooka Exp $
#
RUMPTOP= ${.CURDIR}/../../..
RUMP_ISMODULE= # defined
.include "${RUMPTOP}/Makefile.rump"

28
sys/rump/ldscript.rump Normal file
View File

@ -0,0 +1,28 @@
/* $NetBSD: ldscript.rump,v 1.1 2009/12/12 17:10:19 pooka Exp $ */
/*
* From binutils 2.19 onwards (in NetBSD) binutils ld PROVIDEs
* __start/__stop for orphaned sections. This means that
* __start_link_set_modules/__stop_link_set_modules will no
* longer automatically be present in shared libraries. This
* ldscript forces those symbols to be present for all rump
* shared lib components.
*/
SECTIONS
{
link_set_modules :
{
__start_link_set_modules = .;
*(link_set_modules);
__stop_link_set_modules = .;
}
link_set_domains :
{
__start_link_set_domains = .;
*(link_set_domains);
__stop_link_set_domains = .;
}
}
INSERT AFTER .data;

View File

@ -1,14 +0,0 @@
/* $NetBSD: rump_domain.c,v 1.1 2009/09/13 22:51:42 pooka Exp $ */
/*
* Force reference to __start_link_set_domains, so that the
* binutils 2.19 linker does not lose the symbol due to it being
* PROVIDEd in 2.19 as opposed to earlier versions where it was
* defined.
*
* Note: look into this again when all platforms use 2.19
*/
extern void *__start_link_set_domains;
void *rump_start_domains = &__start_link_set_domains;
extern void *__stop_link_set_domains;
void *rump_stop_domains = &__stop_link_set_domains;

View File

@ -1,14 +0,0 @@
/* $NetBSD: rump_module.c,v 1.1 2009/09/13 22:51:42 pooka Exp $ */
/*
* Force reference to __start_link_set_modules, so that the
* binutils 2.19 linker does not lose the symbol due to it being
* PROVIDEd in 2.19 as opposed to earlier versions where it was
* defined.
*
* Note: look into this again when all platforms use 2.19
*/
extern void *__start_link_set_modules;
void *rump_start_modules = &__start_link_set_modules;
extern void *__stop_link_set_modules;
void *rump_stop_modules = &__stop_link_set_modules;

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.3 2009/09/13 22:51:42 pooka Exp $
# $NetBSD: Makefile,v 1.4 2009/12/12 17:10:19 pooka Exp $
#
.PATH: ${.CURDIR}/../../../../kern
@ -10,7 +10,5 @@ SRCS+= component.c
CFLAGS+= -Wno-pointer-sign
RUMP_ISDOMAIN=
.include <bsd.lib.mk>
.include <bsd.klinks.mk>

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.6 2009/09/13 22:51:42 pooka Exp $
# $NetBSD: Makefile,v 1.7 2009/12/12 17:10:19 pooka Exp $
#
.PATH: ${.CURDIR}/../../../../net
@ -12,8 +12,6 @@ SRCS+= component.c
CPPFLAGS+= -I${.CURDIR}/opt -I${.CURDIR}/../libnetinet/opt
RUMP_ISDOMAIN=
.include "${.CURDIR}/../libnetinet/Makefile.inc"
.include <bsd.lib.mk>

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.4 2009/09/13 22:51:42 pooka Exp $
# $NetBSD: Makefile,v 1.5 2009/12/12 17:10:20 pooka Exp $
#
LIB= rumpnet_sockin
@ -8,7 +8,5 @@ SRCS+= component.c
CPPFLAGS+= -I${RUMPTOP}/librump/rumpkern
RUMP_ISDOMAIN=
.include <bsd.lib.mk>
.include <bsd.klinks.mk>