diff options
author | dfr <dfr@FreeBSD.org> | 1997-05-13 10:23:47 +0000 |
---|---|---|
committer | dfr <dfr@FreeBSD.org> | 1997-05-13 10:23:47 +0000 |
commit | b0fdd73677eea5df875efc2599d480f7d29fa246 (patch) | |
tree | 5bc960944dbc3e634f3956f9481a64aa7ff34394 /gnu | |
parent | bbffd7053b45f95b65ff661f1d6ece91289c4dc4 (diff) | |
download | FreeBSD-src-b0fdd73677eea5df875efc2599d480f7d29fa246.zip FreeBSD-src-b0fdd73677eea5df875efc2599d480f7d29fa246.tar.gz |
Changes to support the kernel linker:
Add a -Bforcedynamic option which generates a dynamic object even
if no shared libraries were given in the link.
Make RRS in text section warnings conditional on "-assert pure-text"
so that I can link non-PIC kernel modules without tons of link
errors. Changes to bsd.lib.mk to follow.
Fix a couple of bugs exposed by the fact that the kernel is not
linked at zero.
Reviewed by: jdp
Diffstat (limited to 'gnu')
-rw-r--r-- | gnu/usr.bin/ld/dynamic.h | 5 | ||||
-rw-r--r-- | gnu/usr.bin/ld/ld.c | 14 | ||||
-rw-r--r-- | gnu/usr.bin/ld/rrs.c | 11 |
3 files changed, 22 insertions, 8 deletions
diff --git a/gnu/usr.bin/ld/dynamic.h b/gnu/usr.bin/ld/dynamic.h index 1231a62..c1890db 100644 --- a/gnu/usr.bin/ld/dynamic.h +++ b/gnu/usr.bin/ld/dynamic.h @@ -27,7 +27,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id$ + * $Id: dynamic.h,v 1.3 1997/02/22 15:46:18 peter Exp $ */ #ifndef __DYNAMIC_H__ @@ -279,6 +279,9 @@ extern int link_mode; of archives */ #define SHAREABLE 8 /* Build a shared object */ #define SILLYARCHIVE 16 /* Process .sa companions, if any */ +#define FORCEDYNAMIC 32 /* Force dynamic output even if no + shared libraries included */ +#define WARNRRSTEXT 64 /* Warn about rrs in text */ extern FILE *outstream; /* Output file. */ extern struct exec outheader; /* Output file header. */ diff --git a/gnu/usr.bin/ld/ld.c b/gnu/usr.bin/ld/ld.c index 257df1b..089dba4 100644 --- a/gnu/usr.bin/ld/ld.c +++ b/gnu/usr.bin/ld/ld.c @@ -32,7 +32,7 @@ static char sccsid[] = "@(#)ld.c 6.10 (Berkeley) 5/22/91"; Set, indirect, and warning symbol features added by Randy Smith. */ /* - * $Id: ld.c,v 1.43 1997/04/11 17:08:56 bde Exp $ + * $Id: ld.c,v 1.44 1997/04/25 19:43:19 bde Exp $ */ /* Define how to initialize system-dependent header fields. */ @@ -448,6 +448,8 @@ classify_arg(arg) return 1; if (!strcmp(&arg[2], "dynamic")) return 1; + if (!strcmp(&arg[2], "forcedynamic")) + return 1; case 'T': if (arg[2] == 0) @@ -533,6 +535,8 @@ decode_command(argc, argv) link_mode &= ~DYNAMIC; else if (strcmp(string, "dynamic") == 0) link_mode |= DYNAMIC; + else if (strcmp(string, "forcedynamic") == 0) + link_mode |= DYNAMIC|FORCEDYNAMIC; else if (strcmp(string, "symbolic") == 0) link_mode |= SYMBOLIC; else if (strcmp(string, "forcearchive") == 0) @@ -546,6 +550,10 @@ decode_command(argc, argv) link_mode &= ~SILLYARCHIVE; #endif } + if (!strcmp(argv[i] + 1, "assert")) { + if (!strcmp(string, "pure-text")) + link_mode |= WARNRRSTEXT; + } if (argv[i][1] == 'A') { if (p != file_table) errx(1, "-A specified before an input file other than the first"); @@ -633,6 +641,8 @@ decode_option(swt, arg) return; if (!strcmp(swt + 1, "Bdynamic")) return; + if (!strcmp(swt + 1, "Bforcedynamic")) + return; if (!strcmp(swt + 1, "Bsymbolic")) return; if (!strcmp(swt + 1, "Bforcearchive")) @@ -2624,7 +2634,7 @@ write_header() */ flags = 0; - if (oldmagic && (flags & EX_DPMASK)) + if (oldmagic && (flags & EX_DPMASK) && !(link_mode & FORCEDYNAMIC)) warnx("Cannot set flag in old magic headers\n"); N_SET_FLAG (outheader, flags); diff --git a/gnu/usr.bin/ld/rrs.c b/gnu/usr.bin/ld/rrs.c index 9e0ff8b..3502ee0 100644 --- a/gnu/usr.bin/ld/rrs.c +++ b/gnu/usr.bin/ld/rrs.c @@ -27,7 +27,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: rrs.c,v 1.20 1997/02/22 15:46:23 peter Exp $ + * $Id: rrs.c,v 1.21 1997/04/25 15:26:12 jdp Exp $ */ #include <sys/param.h> @@ -295,7 +295,8 @@ claim_rrs_reloc(entry, rp, sp, relocation) { struct relocation_info *r = rrs_next_reloc(); - if (rp->r_address < text_start + text_size) + if (rp->r_address < text_start + text_size + && (link_mode & WARNRRSTEXT)) warnx("%s: RRS text relocation at %#x for \"%s\"", get_file_name(entry), rp->r_address, demangle(sp->name)); @@ -693,7 +694,7 @@ consider_rrs_section_lengths() rrs_section_type = RRS_NONE; else if (link_mode & SHAREABLE) rrs_section_type = RRS_FULL; - else if (number_of_shobjs == 0 /*&& !(link_mode & DYNAMIC)*/) { + else if (number_of_shobjs == 0 && !(link_mode & FORCEDYNAMIC)) { /* * First slots in both tables are reserved * hence the "> 1" condition @@ -947,7 +948,7 @@ write_rrs_data() if (rrs_section_type == RRS_NONE) return; - pos = rrs_data_start + (N_DATOFF(outheader) - DATA_START(outheader)); + pos = rrs_data_start + N_TXTOFF(outheader) - text_start; if (fseek(outstream, pos, SEEK_SET) != 0) err(1, "write_rrs_data: fseek"); @@ -997,7 +998,7 @@ write_rrs_text() if (rrs_section_type == RRS_PARTIAL) return; - pos = rrs_text_start + (N_TXTOFF(outheader) - TEXT_START(outheader)); + pos = rrs_text_start + N_TXTOFF(outheader) - text_start; if (fseek(outstream, pos, SEEK_SET) != 0) err(1, "write_rrs_text: fseek"); |