Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 Nov 2012 19:20:32 +0800
From:      pete <petechou@gmail.com>
To:        Erik Cederstrand <erik@cederstrand.dk>
Cc:        freebsd-toolchain@freebsd.org
Subject:   Re: crunchide breaks object files when using mclinker to do base system linking
Message-ID:  <CANWS6nfT4iGkbz1tVgJARX18qSDWBV=Qg0RxO%2BZ%2BioKH%2Bs%2BGGg@mail.gmail.com>
In-Reply-To: <AE74F0D1-483A-4BAB-B7FA-5DD657C94E7A@cederstrand.dk>
References:  <CANWS6neEevzNZjcr%2Bgkk1xw1cG3%2Bc%2BJ6O6SK-43m5S%2BWMDrB7g@mail.gmail.com> <AE74F0D1-483A-4BAB-B7FA-5DD657C94E7A@cederstrand.dk>

next in thread | previous in thread | raw e-mail | index | archive | help
I made a patch at
http://www.freebsd.org/cgi/query-pr.cgi?pr=bin/174011

Not sure if it looks good to you since the changes are not small.

With this patch, crunchide is able to handle object files generated by both
gold and mclinker. And if using input from gnu ld, patched crunchide
produces exactly the same output as before. However, now I check my patch
on X86 FreeBSD only.

Thanks,
Pete



On Tue, Nov 27, 2012 at 4:16 PM, Erik Cederstrand <erik@cederstrand.dk>wrote:

> Den 27/11/2012 kl. 09.00 skrev pete <petechou@gmail.com>:
>
> > Hi,
> >
> > I meet a problem when using mclinker to do base system linking. And the
> > problem is crunchide is gnu ld specific. it presumes the section layout
> of
> > a object file is like what gnu ld generates.
> >
> > To make it clear, gnu ld would generate the following layout. And
> crunchide
> > will update elf section header, symbol table, and then string table. (The
> > string table is likely enlarged.)
> >
> > ld -dc -r -o cat.lo cat_stub.o
> > /usr/obj/usr/src/rescue/rescue//usr/src/bin/cat/cat.o
> > crunchide -k _crunched_cat_stub cat.lo
> >
> > ----gnu ld------------
> > + elf header         +
> > ----------------------
> > +                    +
> > +                    +
> > ----------------------
> > + elf section header +
> > ----------------------
> > + symbol table       +
> > ----------------------
> > + string table       +
> > ----------------------
> >
> > However, mclinker does not produce this layout, but put elf section
> header
> > in the end of file. And then crunchide will break the object file
> generated
> > by mclinker. (elf section header is overwritten by new strings)
> >
> > I know the layout generated by gold linker is also different to gnu ld.
> On
> > the other hand, we can find only ELF header is required to be fixed in
> *"System
> > V Application Binary Interface*".
> >
> > For mclinker, I think it's not difficult to add the change to be
> compatible
> > with gnu ld. But do you think if it will be better to modify crunchide
> > utility to support more elf linkers?
>
>
> Unless you have compelling technical reasons to keep your layout, I think
> it's better for mclinker to be as compatible with GNU ld as possible, even
> though your layout also adheres to the standards. If other tools in FreeBSD
> or other platforms also make assumptions about the header layout, you'll
> end up patching lots of tools instead of working on mclinker.
>
> With that in mind, I also think it's worthwhile to patch our crunchide to
> be more permissive. If you have the resources, please send patches.
>
> Thanks,
> Erik



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CANWS6nfT4iGkbz1tVgJARX18qSDWBV=Qg0RxO%2BZ%2BioKH%2Bs%2BGGg>