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]

Puzziling Behavior when Adding a Section


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.

-Nathan Leung


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