This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: ld -Ttext 0x80000 causes ld.so segfault on ppc-unknown-linux-gnu
- To: anton at mips dot complang dot tuwien dot ac dot at
- Subject: Re: ld -Ttext 0x80000 causes ld.so segfault on ppc-unknown-linux-gnu
- From: Alan Modra <alan at linuxcare dot com dot au>
- Date: Sat, 8 Jul 2000 23:33:08 +1000 (EST)
- cc: binutils at sourceware dot cygnus dot com
I started playing with this a little and discoverd a silly bug in the
"--section-start SECTION=ADDR", fixed with the patch later in this
email.
There are a number of problems that need fixing before -Ttext=addr will
work as you might expect. For starters, SIZEOF_HEADERS in default linker
scripts causes "Not enough room for program headers". Secondly, -Ttext
should probably drag all the other read-only sections along too. There
are other nasty problems on x86-linux too, like the .interp section needs
to sit in the same page as the elf header (I think it's still like that -
haven't checked for a while). The simple answer is to generate your own
linker script file, and pass "-Wl,-T,yourscript" to the compiler.
Sidenote: --section-start .init=xxx can generate a .init section with the
wrong attributes. Talk about a can of worms!
I'm checking the following in.
ld/ChangeLog
* lexsup.c (parse_args): Copy section name.
Alan Modra
--
Linuxcare. Support for the Revolution.
Index: lexsup.c
===================================================================
RCS file: /cvs/src/src/ld/lexsup.c,v
retrieving revision 1.15
diff -u -p -r1.15 lexsup.c
--- lexsup.c 2000/05/22 21:58:40 1.15
+++ lexsup.c 2000/07/08 12:48:06
@@ -847,6 +847,8 @@ parse_args (argc, argv)
case OPTION_SECTION_START:
{
char *optarg2;
+ char *sec_name;
+ int len;
/* Check for <something>=<somthing>... */
optarg2 = strchr (optarg, '=');
@@ -869,12 +871,15 @@ parse_args (argc, argv)
xexit (1);
}
- optarg2[-1] = '\0';
+ /* We must copy the section name as set_section_start
+ doesn't do it for us. */
+ len = optarg2 - optarg;
+ sec_name = xmalloc (len);
+ memcpy (sec_name, optarg, len - 1);
+ sec_name[len - 1] = 0;
/* Then set it... */
- set_section_start (optarg, optarg2);
-
- optarg2[-1] = '=';
+ set_section_start (sec_name, optarg2);
}
break;
case OPTION_TBSS: