This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Strip broke for me in 2.15...


Nick Clifton wrote:

Hi David,

The file is already stripped, however running strip-2.15 on it again, screws up the alignment.


Why would you run strip on an already stripped file ?


Normally I would not do this. The reason I did it in this case was that it was the smallest test case I could come up with in short order.


Anyway, the problem is a difference in the page size between the toolchain that was used to create the original binary file and the mipsisa32el-linux toolchain that you are using. Most MIPS ELF toolchains use a page size of 0x1000. (This is reflected in the alignment of the two LOAD segments in the original xilleon-remote binary).

The mipsisa32el-linux toolchain however uses a page size of 0x10000, (ie 16 times the other page size). So when strip (or objcopy or the linker or any other program that uses the BFD library and processes the xilleon-remote binary) attempts to build a new program header table from the input file it discovers that although the original input segments are aligned to a 0x1000 byte boundary they are not aligned to a 0x10000 byte boundary. Hence the code concludes that these segments are not supposed to be aligned, and so resets their alignment down to the maximum alignment of any of the sections that they contain.

The reason for the difference is that the IRIX5 OS uses a page size of 0x1000 whereas Linux and the SVR4 MIPS ABI both mandate a page size of 0x10000.

So...this is not really a bug, it is a feature. I have a couple of suggestions for a workaround, but neither of them are simple: If you can arrange for the original xilleon-remote binary to be created by a MIPS ELF toolchain with a page size of 0x10000 then the problem should disappear. If you can build a toolchain that is targeted at both mipsisa32el-linux and mips-elf then you could use a command line like this to perform the strip:


I am running an extremely hacked up conglomeration of gcc-3.3.1 and now several intermixed versions of binutils. I guess that this shows what can happen if you don't know what you are doing.

I think the real solution is to configure everything as mipsel-linux and not inter-mix versions. This is what I have been working towards.

Thanks for your help.



strip --input-target=elf32-littlemips --output-target=elf32-littlemips xilleon-remote -o xilleon-remote.stripped

Cheers
  Nick

PS. In case you are interested the patch to the 2.15 sources that caused this change in behaviour was this one:

bfd/ChangeLog
2004-01-05  Maciej W. Rozycki  <macro@ds2.pg.gda.pl>

    * elf32-mips.c (ELF_MAXPAGESIZE): Redefine for traditional
    targets to support pages of up to 64kB.
    (elf32_bed): Redefine to get a separate backend data structure for
    traditional targets.
    * elf64-mips.c (ELF_MAXPAGESIZE): Redefine for traditional
    targets to support pages of up to 64kB.
    (elf64_bed): Redefine to get a separate backend data structure for
    traditional targets.
    * elfn32-mips.c (ELF_MAXPAGESIZE): Redefine for traditional
    targets to support pages of up to 64kB.
    (elf32_bed): Redefine to get a separate backend data structure for
    traditional targets.




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]