From 418625be7c16f07404130897715e1b286f7224b0 Mon Sep 17 00:00:00 2001 From: Keith Bostic Date: Mon, 6 Jul 1992 20:56:01 -0800 Subject: [PATCH] Sparc fixes from Chris Torek -p to pad text, set NODUMP flag on output, minor speedups SCCS-vsn: usr.bin/ld/ld.c 6.12 --- usr/src/usr.bin/ld/ld.c | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/usr/src/usr.bin/ld/ld.c b/usr/src/usr.bin/ld/ld.c index 850c7ec7d1..612e57b57d 100644 --- a/usr/src/usr.bin/ld/ld.c +++ b/usr/src/usr.bin/ld/ld.c @@ -6,7 +6,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)ld.c 6.11 (Berkeley) %G%"; +static char sccsid[] = "@(#)ld.c 6.12 (Berkeley) %G%"; #endif /* not lint */ /* Linker `ld' for GNU @@ -79,6 +79,11 @@ char *progname; #define INITIALIZE_HEADER outheader.a_mid = MID_HP300 #endif +#ifdef sparc +#define INITIALIZE_HEADER \ + (outheader.a_mid = MID_SUN_SPARC, outheader.a_toolversion = 1) +#endif + /* * Ok. Following are the relocation information macros. If your * system should not be able to use the default set (below), you must @@ -710,6 +715,9 @@ enum { STRIP_NONE, STRIP_ALL, STRIP_DEBUGGER } strip_symbols; This is irrelevant if STRIP_NONE. */ enum { DISCARD_NONE, DISCARD_ALL, DISCARD_L } discard_locals; +/* Do we want to pad the text to a page boundary? */ +int padtext; + /* 1 => write load map. */ int write_map; @@ -826,6 +834,7 @@ main (argc, argv) strip_symbols = STRIP_NONE; trace_files = 0; discard_locals = DISCARD_NONE; + padtext = 0; entry_symbol = 0; write_map = 0; relocatable_output = 0; @@ -1224,6 +1233,10 @@ decode_option (swt, arg) output_filename = arg; return; + case 'p': + padtext = 1; + return; + case 'r': relocatable_output = 1; magic = OMAGIC; @@ -2359,6 +2372,12 @@ digest_symbols () text_pad = ((text_end + page_size - 1) & (- page_size)) - text_end; text_size += text_pad; } + if (padtext) + { + int text_end = text_size; + text_pad = ((text_end + page_size - 1) & (- page_size)) - text_end; + text_size += text_pad; + } #ifdef _N_BASEADDR /* SunOS 4.1 N_TXTADDR depends on the value of outheader.a_entry. */ @@ -3208,9 +3227,10 @@ write_output () if (fstat (outdesc, &statbuf) < 0) perror_name (output_filename); - filemode = statbuf.st_mode; + (void) fchflags(outdesc, statbuf.st_flags | NODUMP); - chmod (output_filename, filemode & ~0111); + filemode = statbuf.st_mode; + (void) fchmod (outdesc, filemode & ~0111); /* Output the a.out header. */ write_header (); @@ -3229,10 +3249,10 @@ write_output () /* Copy any GDB symbol segments from input files. */ write_symsegs (); - close (outdesc); - - if (chmod (output_filename, filemode | 0111) == -1) + if (fchmod (outdesc, filemode | 0111) == -1) perror_name (output_filename); + + close (outdesc); } void modify_location (), perform_relocation (), copy_text (), copy_data (); -- 2.20.1