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
This commit is contained in:
parent
f154fbdaa1
commit
3c0a9567e5
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=25774
@ -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. */
|
||||
|
@ -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);
|
||||
|
@ -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");
|
||||
|
||||
|
@ -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. */
|
||||
|
Loading…
Reference in New Issue
Block a user