This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: Puzziling Behavior when Adding a Section
- From: Daniel Jacobowitz <drow at mvista dot com>
- To: Nathan Leung <fkis at imsa dot edu>
- Cc: binutils at sources dot redhat dot com
- Date: Wed, 24 Jul 2002 16:50:11 -0400
- Subject: Re: Puzziling Behavior when Adding a Section
- References: <Pine.LNX.4.33.0207241509590.30873-100000@pollux.imsa.edu>
On Wed, Jul 24, 2002 at 03:21:00PM -0500, Nathan Leung wrote:
> Hello,
>
> I am currently working on an embedded systems project and I have a bug
> (feature?) that is confusing me. I am trying to add a section before the
> text section. Eventually, it will be a relevent section and do something
> different, but for now, it shouldn't do anything different from the
> original. Well.. I think it's easier to see from the link scripts.
>
> This is the original, which yields correct output:
>
> MEMORY
> {
> ROM (rx): ORIGIN = 0xa0000000, LENGTH = 0x8000
> RAM (rw): ORIGIN = 0x7c001000, LENGTH = 0x1800
> STACK (rw): ORIGIN = 0x7c002800, LENGTH = 0x800
> SDRAM (rw): ORIGIN = 0xac000000, LENGTH = 0x100000
> }
>
> SECTIONS
> {
> .text :
> {
> ../shared/blah.o(.textinit)
> *(.text)
> *(.rodata)
> } > ROM
> .data : ...
>
> blah.o is an assembly file compiled for the SuperH architecture. The text
> from this file has been put into a section called "textinit"
>
>
> This is the version with a new section, which yields weird output:
>
> MEMORY
> {
> ROM (rx): ORIGIN = 0xa0000000, LENGTH = 0x8000
> RAM (rw): ORIGIN = 0x7c001000, LENGTH = 0x1800
> STACK (rw): ORIGIN = 0x7c002800, LENGTH = 0x800
> SDRAM (rw): ORIGIN = 0xac000000, LENGTH = 0x100000
> }
>
> SECTIONS
> {
> .textinit :
> {
> ../shared/sh6-entry-ncl.o(.textinit)
> } > ROM
> .text :
> {
> *(.text)
> *(.rodata)
> } > ROM
> .data : ...
>
> When I do an objdump to view the section info this is what I get for the
> first link file:
>
> Sections:
> Idx Name Size VMA LMA File off Algn
> 0 .text 00001d20 a0000000 a0000000 00010000 2**10
> CONTENTS, ALLOC, LOAD, READONLY, CODE
>
> This is what I get from the second file:
>
> Sections:
> Idx Name Size VMA LMA File off Algn
> 0 .textinit 00000c00 a0000000 a0000000 00002000 2**10
> CONTENTS, READONLY, CODE
> 1 .text 00001120 a0000c00 a0000c00 00000c00 2**5
> CONTENTS, ALLOC, LOAD, READONLY, CODE
>
> I noticed that the File offset is different.. though I have no idea why..
> I think that is probably the cause of my problems, however I am not sure
> how to fix this discrepency. Any help is appreciated.
More likely, the missing ALLOC and LOAD flags are your problem. Try
describing the section as '.section ".textinit", "ax", @progbits'.
--
Daniel Jacobowitz Carnegie Mellon University
MontaVista Software Debian GNU/Linux Developer