binutils breaks dosemu
Alan Modra
amodra@bigpond.net.au
Sun Mar 17 18:55:00 GMT 2002
On Sun, Mar 17, 2002 at 11:56:44AM -0800, H . J . Lu wrote:
>
> Here is a testcase.
>
> # gcc x.c
> # a.out
> zsh: 3646 segmentation fault ./a.out
>
>
> H.J.
> --x.c--
> #include <stdio.h>
>
> static int foo __attribute__ ((section(".text.xx"))) = 0;
>
> main (int argc, char **argv)
> {
> fprintf (stdout, "hello\n");
> }
I think we probably want to either not fudge the .text read-only
flag for ELF, or set it a little earlier so that the code in
elf32-i386.c:readonly_dynrelocs works properly.
ld/ChangeLog
* ldmain.c (main): Move .text readonly flag fudges from here..
* ldlang.c (lang_process): ..to here.
--
Alan Modra
IBM OzLabs - Linux Technology Centre
Index: ld/ldlang.c
===================================================================
RCS file: /cvs/src/src/ld/ldlang.c,v
retrieving revision 1.77
diff -u -p -r1.77 ldlang.c
--- ldlang.c 2002/03/14 10:39:46 1.77
+++ ldlang.c 2002/03/18 02:14:24
@@ -4198,6 +4198,22 @@ lang_process ()
/* Find any sections not attached explicitly and handle them. */
lang_place_orphans ();
+ if (! link_info.relocateable)
+ {
+ /* Look for a text section and set the readonly attribute in it. */
+ asection *found = bfd_get_section_by_name (output_bfd, ".text");
+
+ if (found != (asection *) NULL)
+ {
+ if (config.text_read_only)
+ found->flags |= SEC_READONLY;
+ else
+ found->flags &= ~SEC_READONLY;
+ }
+ }
+
+ /* Do anything special before sizing sections. This is where ELF
+ and other back-ends size dynamic sections. */
ldemul_before_allocation ();
/* We must record the program headers before we try to fix the
Index: ld/ldmain.c
===================================================================
RCS file: /cvs/src/src/ld/ldmain.c,v
retrieving revision 1.43
diff -u -p -r1.43 ldmain.c
--- ldmain.c 2002/02/15 02:11:05 1.43
+++ ldmain.c 2002/03/18 02:14:25
@@ -404,20 +404,6 @@ main (argc, argv)
/* Print error messages for any missing symbols, for any warning
symbols, and possibly multiple definitions. */
- if (! link_info.relocateable)
- {
- /* Look for a text section and switch the readonly attribute in it. */
- asection *found = bfd_get_section_by_name (output_bfd, ".text");
-
- if (found != (asection *) NULL)
- {
- if (config.text_read_only)
- found->flags |= SEC_READONLY;
- else
- found->flags &= ~SEC_READONLY;
- }
- }
-
if (link_info.relocateable)
output_bfd->flags &= ~EXEC_P;
else
More information about the Binutils
mailing list