This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: binutils breaks dosemu
On Sun, Mar 17, 2002 at 10:49:08AM -0800, H . J . Lu wrote:
> On Sun, Mar 17, 2002 at 09:30:18AM -0800, H . J . Lu wrote:
> > On Sun, Mar 17, 2002 at 04:35:39PM +0100, Andreas Schwab wrote:
> > > "H . J . Lu" <hjl@lucon.org> writes:
> > >
> > > |> On Sat, Mar 16, 2002 at 11:07:48AM +0100, Arkadiusz Miskiewicz wrote:
> > > |> >
> > > |> > Hi,
> > > |> >
> > > |> > We have problem with binutils 2.11.92.0.12.3 - 2.12.90.0.1 - binutils
> > > |> > break dosemu. dosemu segfaults even before main().
> > > |> >
> > > |> >
> > > |> > Right now 2.11.90.0.19 is working fine for us (I didn't test binutils
> > > |> > from 2.11.90.0.19 (last working version for us) to 2.11.92.0.12.3 (version =
> > > |> > with which we
> > > |> > noticed that is breaks dosemu)).
> > > |>
> > > |> I can duplicate the problem with dosemu 1.0.2 from www.dosemu.org. It
> > > |> has something to do with the change to avoid copy relocations. ld.so
> > > |> died while trying to resolve stdout. In dosemu, it is
> > >
> > > Check out a newer version of dosemu. 1.0.2 is broken in that it tries to
> > > link ELF with a.out (as generated by as86/ld86). The end result is an
> >
> > It should work. Ld should set DT_TEXTREL in this case.
> >
> > > executable with text relocations, but no DT_TEXTREL. dosemu 1.1 does not
> > > use as86 any more.
>
> I am not sure if as86/ld86 is the problem. I think somehow ld failed
> to detect there are relocations against the readonly sections.
>
I found the problem. If there are any input sections like
Idx Name Size VMA LMA File off Algn
0 .text 00010000 0000000000000000 0000000000000000 00000020 2**3
CONTENTS, ALLOC, LOAD, CODE
that is an input .text section is not marked readonly, ld will do the
wrong thing. I am not sure how ld should handle the writable input
.text section. However, I don't think ld should generate the bad
binary silently.
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");
}