bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MIPS version of LD not honoring -Ttext for .MIPS.abiflags section


From: Geoff Mottram
Subject: Re: MIPS version of LD not honoring -Ttext for .MIPS.abiflags section
Date: Wed, 25 May 2016 12:45:56 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0

Hi Nick,

Thanks for your quick response. I will try a linker script. The problem with the first approach is I would like the linker to just pack the MIPS abiflags section with the .text, .got and .rodata sections so I don't have to calculate the size of the other sections ahead of time.

The thing that is great about the -Ttext option is the way it will set a new default starting address and things will just fall into place. I suspect there is some magic needed in the default linker script for this new section to make this happen.

After I wrote, I did some more digging and found a different application within u-boot that did not have this problem and they did use a linker script (which I have added, below). Oddly, it works (perhaps accidentally), even though it does not mention the abiflags section explicitly.

Thanks again for taking the time to respond.

Best,

Geoff

On 05/25/2016 10:21 AM, Nick Clifton wrote:
Hi Geoff,

When compiling one of the u-boot demo applications using the
"-Ttext 0x80200000" option, the resulting elf file has a
.MIPS.abiflags section with a load address of "004000b8".
Have you tried adding:

   --start-address=.MIPS.abiflags=0x80300000

(or whatever address you want) ?


The problem is the linker is not honouring the -Ttext flag
for the .MIPS.abiflags section like it does for the .got,
.rodata and .bss sections.
True.  I suspect that this is because it has a processor
specific type, rather than a generic section type, although
I have not verified this.

The correct way to solve this would be to use your own linker
script.  Then you can the start address of the text section
and any other section you like, and make sure that the sections
are loaded where you want them to be loaded.

Cheers
   Nick

/*
 * (C) Copyright 2003
 * Wolfgang Denk Engineering, <address@hidden>
 *
 * SPDX-License-Identifier: GPL-2.0+
 */

/*
OUTPUT_FORMAT("elf32-bigmips", "elf32-bigmips", "elf32-bigmips")
*/
OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradlittlemips")
OUTPUT_ARCH(mips)
SECTIONS
{
    .text       :
    {
      *(.text*)
    }

    . = ALIGN(4);
    .rodata  : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }

    . = ALIGN(4);
    .data  : { *(.data*) }

    . = .;
    _gp = ALIGN(16) + 0x7ff0;

    .got : {
      __got_start = .;
      *(.got)
      __got_end = .;
    }

    .sdata  : { *(.sdata*) }

    . = ALIGN(4);
    __bss_start = .;
    .sbss (NOLOAD) : { *(.sbss*) }
    .bss (NOLOAD)  : { *(.bss*) . = ALIGN(4); }

    _end = .;
}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]