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]

Difficulty in using a linker script


Hello all,

I'm having a little bit of difficulty getting my linker script to work
correctly and was hoping that someone would be able to point out the
error of my ways.

I basically have 3 sections, .boot_code, .text and .reset_vector.  I
have to have .reset_vector to be at the end of the code, whose only
instruction jumps to the start of the .boot_code section.  My final
executable is a binary file that is created using objcopy.

All assemble and link fine, but the .reset_vector section does not
show up in the final binary and the final binary is not 4KB in size
(0xFFFF000 - 0xFFFFFFFF.)

I checked for the existence of the instruction in the section
.reset_vector using khexedit looking for the instruction 0x4BFFF005 at
the end of the binary file but did not find it.

Next I used objdump -d output.o to determine if the section or
instructions were present in the file.  After not seeing it, I used
objdump -D output.o to see if maybe it was not marked as as section
that was not expected to contain an instruction and it showed up with
the correct load address.

Why doesn't the .reset_vector section get marked as a section with
instructions and get listed with the .boot_code and .text sections?

Why does the section get listed as CONTENTS, READONLY while .boot_code
gets CONTENTS, ALLOC, LOAD, READONLY, CODE?

Any ideas of what needs to happen to get this to all just work?

I've tried the linker script with both .reset_vector declared first
and after the .text section.

Detailed information follows.

objdump -h output.o:

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .reset_vector 00000004  fffffffc  fffffffc  0000f300  2**0
                  CONTENTS, READONLY
  1 .boot_code    000002d8  fffff000  fffff000  0000f000  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  2 .text         00000025  fffff2d8  fffff2d8  0000f2d8  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  3 .data         00000000  fffff2fd  fffff2fd  0000f2fd  2**0
                  CONTENTS, ALLOC, LOAD, DATA
  4 .sdata        00000000  fffff300  fffff300  0000f300  2**2
                  CONTENTS, ALLOC, LOAD, DATA
  5 .bss          00000000  fffff300  fffff300  0000f300  2**0
                  ALLOC
  6 .sdata2       00000000  fffff300  fffff300  0000f300  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA

ldscript:

ARCH(powerpc)
ENTRY(.reset_vector)
SECTIONS
{
   .reset_vector 0xFFFFFFFC :
   {
      resetvector.o (.reset_vector)
   } = 0xFFFF

   .boot_code 0xFFFFF000 :
   {
      Start.o (.boot_code)
      tlb.o (.boot_code)
   } = 0xFFFF

   .text :
   {
      Start.o (.text)
   } = 0xFFFF
}

compile commands:

as -m440 -mregnames -many --warn X.s -o X.o
ld -T ldscript.lds Start.o tlb.o resetvector.o -o output.o
objcopy -S -O binary output.o output.bin

Regards,
-- 
Bradley Remedios
bremedios@gmail.com


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