This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos 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]

Linker Output


Hi All,

Platform is Intel PXA26x (ARM core).

I am compiling a ROM/RAM application (resides in ROM and loaded to RAM
for execution) and I am having problems with placement of program
segments (the .hdrs and .hdrs.chksum)).

The .ldi used to generate the target.ld looks OK to me and I have also
generated a linker map file to assist but again this looks OK. I cannot
see how or why the linker is placing these particluar segments at the
address it does - any help appreciated.

I am expecting the .hdrs segment to not get loaded at all and the
.hdrs.chksum segment to appear at address 0x45000. This section is
aligned to 0x100 so I would expect the next segment to begin at 0x40100.
The sections look fine, but the segments are incorrect.

I have inlcuded below the .ldi, the generated target.ld and also the
objdump of the resutant .elf.

Thanks in advance for any help.

Andy Atkinson

// eCos memory layout - Tue Jul 02 10:03:04 2002

// This was a generated file a long time ago, but is now maintained by
hand.

#include <cyg/infra/cyg_type.inc>

#define __MLT_ARM_XSCALE_BIOPAD_LDI__
#include CYGHWR_MEMORY_LAYOUT_H

#define FOLLOWING_ALIGNED(_section_, _align_) AT
((LOADADDR(_section_)+SIZEOF(_section_)+_align_-1)&~(_align_-1))
#define PAGE_SIZE CYGMEM_PAGE_SIZE

MEMORY
{
    sysram  : ORIGIN = CYGMEM_REGION_sysram,  LENGTH =
CYGMEM_REGION_sysram_SIZE
    bootram : ORIGIN = CYGMEM_REGION_bootram, LENGTH =
CYGMEM_REGION_bootram_SIZE
    secureram : ORIGIN = CYGMEM_REGION_secureram, LENGTH =
CYGMEM_REGION_secureram_SIZE
    persistram : ORIGIN = CYGMEM_REGION_persistram, LENGTH =
CYGMEM_REGION_persistram_SIZE
    ram     : ORIGIN = CYGMEM_REGION_ram,     LENGTH =
CYGMEM_REGION_ram_SIZE

#ifdef CYGMEM_REGION_rom
    rom       : ORIGIN = CYGMEM_REGION_rom,   LENGTH =
CYGMEM_REGION_rom_SIZE
#endif
#ifdef CYGMEM_REGION_instrument
    instrumentram : ORIGIN = CYGMEM_REGION_instrument, LENGTH =
CYGMEM_REGION_instrument_SIZE
#endif
#ifdef CYGMEM_REGION_log
    logram : ORIGIN = CYGMEM_REGION_log, LENGTH = CYGMEM_REGION_log_SIZE
#endif
}

#if CYGMEM_REGION_ram != 0x44000
#error RAM is not defined correctly
#endif

#ifndef CYGMEM_REGION_rom
#define rom ram
#define CYGMEM_REGION_rom CYGMEM_REGION_ram
#endif

#if CYGMEM_REGION_rom != CYGMEM_REGION_ram
#error ROM is not equal RAM
#endif


/*
 * Define a section to cover the ELF and programme headers.
 */
#define SECTION_hdrs(_region_, _vma_, _lma_)        \
    .hdrs _vma_(NOLOAD) : _lma_ {                   \
        FORCE_OUTPUT;                               \
        __ehdr = ABSOLUTE(.);                       \
        . = . + SIZEOF_HEADERS; } > _region_

/*
 * Pad the headers section/segment to mutliple of 0x100 bytes and
 * provide space for a checksum/crc value.
 */
#define SECTION_hdrs_chksum(_region_, _vma_, _lma_) \
    .hdrs.chksum _vma_ : _lma_ {                    \
        FORCE_OUTPUT;                               \
        . =  ALIGN(0x100)-4;                        \
        __hdrs_segment_chksum = ABSOLUTE(.);        \
        LONG(0xBEEFCAFE); } > _region_

/*
 * Section to reserve space for checksum/crc at end of text segment
 */
#define SECTION_text_chksum(_region_, _vma_, _lma_) \
    .text.chksum _vma_ : _lma_ {                    \
        FORCE_OUTPUT;                               \
        __text_segment_chksum = ABSOLUTE(.);        \
        LONG(0xBEEFCAFE); } > _region_

/*
 * Section to reserve space for checksum/crc at end of data segment
 */
#define SECTION_data_chksum(_region_, _vma_, _lma_) \
    .data.chksum _vma_ : _lma_ {                    \
        FORCE_OUTPUT;                               \
        __data_segment_chksum = ABSOLUTE(.);        \
        LONG(0xBEEFCAFE); } > _region_

/*
 * Place MMU page table sections.
 */
#define SECTION_page_tables(_region_, _vma_,
_lma_)                         \
    .page_tables _vma_ : _lma_ { FORCE_OUTPUT; KEEP(*(.page_tables*)) }
> _region_

/*
 * Place Flash configuration sections.
 */
#define SECTION_flash_config(_region_, _vma_,
_lma_)                          \
    .flash_config _vma_ : _lma_ { FORCE_OUTPUT; KEEP(*(.flash_config*))
KEEP(*(.fconfig*)) } > _region_

/*
 * Place secure bss sections.
 */
#define SECTION_securebss(_region_, _vma_, _lma_)  \
    .securebss _vma_ : _lma_ { FORCE_OUTPUT; *(.securebss*) } > _region_

/*
 * Place persistent bss sections.
 */
#define SECTION_persistbss(_region_, _vma_, _lma_)  \
    .persistbss _vma_ : _lma_ { FORCE_OUTPUT; *(.persistbss*) } >
_region_

#ifdef CYGMEM_REGION_instrument
/*
 * Place instrumentation buffer bss sections.
 */
#define SECTION_instrument(_region_, _vma_, _lma_)  \
    .instrumentbss _vma_ : _lma_ { FORCE_OUTPUT; *(.instrumentbss*) } >
_region_
#endif

#ifdef CYGMEM_REGION_log
/*
 * Place log buffer bss sections.
 */
#define SECTION_log(_region_, _vma_, _lma_)  \
    .logbss _vma_ : _lma_ { FORCE_OUTPUT; *(.logbss*) } > _region_
#endif

/*
 * Define programme headers.
 */
PHDRS
{
#ifndef CYGSEM_HAL_BOOTROM
    hdrs PT_LOAD FILEHDR PHDRS FLAGS(4);
#endif    
    text PT_LOAD               FLAGS(5);
    data PT_LOAD               FLAGS(7);
}

/*
 * Link and locate sections.
 */
SECTIONS
{
    SECTIONS_BEGIN

    SECTION_fixed_vectors       (sysram :NONE,   
0x00020(NOLOAD),        LMA_EQ_VMA)
    SECTION_page_tables         (sysram :NONE,   
0x04000(NOLOAD),        LMA_EQ_VMA)
    SECTION_flash_config        (sysram :NONE,   
0x10000(NOLOAD),        LMA_EQ_VMA)

#ifndef CYGSEM_HAL_BOOTROM
    SECTION_hdrs                (rom :hdrs,      
CYGMEM_REGION_rom,      LMA_EQ_VMA)
    SECTION_hdrs_chksum         (rom :hdrs,       ALIGN
(0x4),            LMA_EQ_VMA)
    SECTION_rom_vectors         (rom :text,       ALIGN
(0x4),            LMA_EQ_VMA)
#else
    SECTION_rom_vectors         (rom :text,      
CYGMEM_REGION_rom,      LMA_EQ_VMA)
#endif

    SECTION_text                (rom :text,       ALIGN
(0x4),            LMA_EQ_VMA)
    SECTION_fini                (rom :text,       ALIGN
(0x4),            LMA_EQ_VMA)
    SECTION_rodata              (rom :text,       ALIGN
(0x4),            LMA_EQ_VMA)
    SECTION_rodata1             (rom :text,       ALIGN
(0x4),            LMA_EQ_VMA)
    SECTION_fixup               (rom :text,       ALIGN
(0x4),            LMA_EQ_VMA)
    SECTION_gcc_except_table    (rom :text,       ALIGN
(0x4),            LMA_EQ_VMA)
#if defined(CYGSEM_HAL_STATIC_MMU_TABLES)
    SECTION_mmu_tables          (rom :text,       ALIGN
(0x4000),         LMA_EQ_VMA)
#endif    
    SECTION_text_chksum         (rom :text,       ALIGN
(0x4),            LMA_EQ_VMA)

#if defined(CYGSEM_HAL_BOOTROM)
    SECTION_data                (bootram :data,  
CYGMEM_REGION_bootram,  FOLLOWING (.text.chksum))
    SECTION_data_chksum         (bootram :data,   ALIGN
(0x4),            FOLLOWING (.data))
    SECTION_bss                 (bootram :data,   ALIGN
(0x4),            FOLLOWING (.data.chksum))
#elif defined(CYG_HAL_STARTUP_ROM)
    SECTION_data                (ram :data,      
CYGMEM_REGION_ram,      FOLLOWING (.text.chksum))
    SECTION_data_chksum         (ram :data,       ALIGN
(0x4),            FOLLOWING (.data))
    SECTION_bss                 (ram :data,       ALIGN
(0x4),            FOLLOWING (.data.chksum))
#else
    SECTION_data                (ram :data,       ALIGN
(PAGE_SIZE),      LMA_EQ_VMA)
    SECTION_data_chksum         (ram :data,       ALIGN
(0x4),            LMA_EQ_VMA)
    SECTION_bss                 (ram :data,       ALIGN
(0x4),            LMA_EQ_VMA)
#endif

#ifndef CYGSEM_HAL_BOOTROM
    CYG_LABEL_DEFN(__hdrs_segment_start) = LOADADDR (.hdrs);
    CYG_LABEL_DEFN(__hdrs_segment_size) = SIZEOF(.hdrs) +
SIZEOF(.hdrs.chksum);
#else
    CYG_LABEL_DEFN(__hdrs_segment_start) = LOADADDR (.rom_vectors);
    CYG_LABEL_DEFN(__hdrs_segment_size) = 0;
#endif    
    CYG_LABEL_DEFN(__text_segment_start) = LOADADDR (.rom_vectors);
    CYG_LABEL_DEFN(__text_segment_size) = LOADADDR (.data) - LOADADDR
(.rom_vectors);

    CYG_LABEL_DEFN(__data_segment_start) = LOADADDR (.data);
    CYG_LABEL_DEFN(__data_segment_size) = LOADADDR (.bss) - LOADADDR
(.data);

    CYG_LABEL_DEFN(__rom_image_start) = LOADADDR (.rom_vectors);
    CYG_LABEL_DEFN(__rom_image_end) = LOADADDR (.bss);
    CYG_LABEL_DEFN(__heap1) = ALIGN (0x8);

    SECTION_securebss           (secureram :NONE,
CYGMEM_REGION_secureram(NOLOAD), LMA_EQ_VMA)
    SECTION_persistbss          (persistram :NONE,
CYGMEM_REGION_persistram(NOLOAD), LMA_EQ_VMA)

#ifdef CYGMEM_REGION_instrument
    SECTION_instrument          (instrumentram :NONE,
CYGMEM_REGION_instrument(NOLOAD), LMA_EQ_VMA)
#endif

#ifdef CYGMEM_REGION_log
    SECTION_log          	(logram :NONE, CYGMEM_REGION_log(NOLOAD),
LMA_EQ_VMA)
#endif

    SECTIONS_END
}


STARTUP(vectors.o)
ENTRY(reset_vector)
INPUT(extras.o)

GROUP(libtarget.a libgcc.a libsupc++.a)
MEMORY
{
    sysram : ORIGIN = ((0x00000000)), LENGTH = (0x00020000)
    bootram : ORIGIN = ((0x00020000)), LENGTH = (0x00020000)
    secureram : ORIGIN = (0xC4000000 +(0x00020000)+(0x00020000)), LENGTH
= (0x00004000)
    persistram : ORIGIN = (0xC4000000
+(0x00020000)+(0x00020000)+(0x00004000)), LENGTH = (0x00001000)
    ram : ORIGIN =
(((0x00020000))+(0x00020000)+(0x00004000)+(0x00001000)), LENGTH =
((0x00200000)-(((0x00020000))+(0x00020000)+(0x00004000)+(0x00001000)))
}
PHDRS
{

    hdrs PT_LOAD FILEHDR PHDRS FLAGS(4);

    text PT_LOAD FLAGS(5);
    data PT_LOAD FLAGS(7);
}




SECTIONS
{
    .debug_aranges 0 : { *(.debug_aranges) } .debug_pubnames 0 : {
*(.debug_pubnames) } .debug_info 0 : { *(.debug_info) } .debug_abbrev 0
: { *(.debug_abbrev) } .debug_line 0 : { *(.debug_line) } .debug_frame 0
: { *(.debug_frame) } .debug_str 0 : { *(.debug_str) } .debug_loc 0 : {
*(.debug_loc) } .debug_macinfo 0 : { *(.debug_macinfo) } .note.arm.ident
0 : { KEEP (*(.note.arm.ident)) }

    .fixed_vectors 0x00020(NOLOAD) : { . = .; KEEP (*(.fixed_vectors)) }
> sysram :NONE
    .page_tables 0x04000(NOLOAD) : { . = .; KEEP(*(.page_tables*)) } >
sysram :NONE
    .flash_config 0x10000(NOLOAD) : { . = .; KEEP(*(.flash_config*))
KEEP(*(.fconfig*)) } > sysram :NONE


    .hdrs
(((0x00020000))+(0x00020000)+(0x00004000)+(0x00001000))(NOLOAD) : { . =
.; __ehdr = ABSOLUTE(.); . = . + SIZEOF_HEADERS; } > ram :hdrs
    .hdrs.chksum ALIGN (0x4) : { . = .; . = ALIGN(0x100)-4;
__hdrs_segment_chksum = ABSOLUTE(.); LONG(0xBEEFCAFE); } > ram :hdrs
    .rom_vectors ALIGN (0x4) : { __rom_vectors_vma = ABSOLUTE(.); . = .;
KEEP (*(.vectors)) } > ram :text __rom_vectors_lma =
LOADADDR(.rom_vectors);




    .text ALIGN (0x4) : { _stext = ABSOLUTE(.); PROVIDE (__stext =
ABSOLUTE(.)); *(.text*) *(.gnu.warning) *(.gnu.linkonce.t.*) *(.init)
*(.glue_7) *(.glue_7t) } > ram :text _etext = .; PROVIDE (__etext = .);
    .fini ALIGN (0x4) : { . = .; *(.fini) } > ram :text
    .rodata ALIGN (0x4) : { . = .; *(.rodata*) *(.gnu.linkonce.r.*) } >
ram :text
    .rodata1 ALIGN (0x4) : { . = .; *(.rodata1) } > ram :text
    .fixup ALIGN (0x4) : { . = .; *(.fixup) } > ram :text
    .gcc_except_table ALIGN (0x4) : { . = .; *(.gcc_except_table) } >
ram :text



    .text.chksum ALIGN (0x4) : { . = .; __text_segment_chksum =
ABSOLUTE(.); LONG(0xBEEFCAFE); } > ram :text
    .data ALIGN (0x1000) : { __ram_data_start = ABSOLUTE (.); *(.data*)
*(.data1) *(.gnu.linkonce.d.*) . = ALIGN (4); KEEP(*( SORT
(.ecos.table.*))) ; . = ALIGN (4); __CTOR_LIST__ = ABSOLUTE (.); KEEP
(*(SORT (.ctors*))) __CTOR_END__ = ABSOLUTE (.); __DTOR_LIST__ =
ABSOLUTE (.); KEEP (*(SORT (.dtors*))) __DTOR_END__ = ABSOLUTE (.);
*(.dynamic) *(.sdata*) *(.gnu.linkonce.s.*) . = ALIGN (4); *(.2ram.*) }
> ram :data __rom_data_start = LOADADDR (.data); __ram_data_end = .;
PROVIDE (__ram_data_end = .); _edata = .; PROVIDE (edata = .); PROVIDE
(__rom_data_end = LOADADDR (.data) + SIZEOF(.data));
    .data.chksum ALIGN (0x4) : { . = .; __data_segment_chksum =
ABSOLUTE(.); LONG(0xBEEFCAFE); } > ram :data
    .bss ALIGN (0x4) : { __bss_start = ABSOLUTE (.); *(.scommon)
*(.dynsbss) *(.sbss*) *(.gnu.linkonce.sb.*) *(.dynbss) *(.bss*)
*(.gnu.linkonce.b.*) *(COMMON) __bss_end = ABSOLUTE (.); } > ram :data



    __hdrs_segment_start = LOADADDR (.hdrs);
    __hdrs_segment_size = SIZEOF(.hdrs) + SIZEOF(.hdrs.chksum);




    __text_segment_start = LOADADDR (.rom_vectors);
    __text_segment_size = LOADADDR (.data) - LOADADDR (.rom_vectors);

    __data_segment_start = LOADADDR (.data);
    __data_segment_size = LOADADDR (.bss) - LOADADDR (.data);

    __rom_image_start = LOADADDR (.rom_vectors);
    __rom_image_end = LOADADDR (.bss);
    __heap1 = ALIGN (0x8);

    .securebss (0xC4000000 +(0x00020000)+(0x00020000))(NOLOAD) : { . =
.; *(.securebss*) } > secureram :NONE
    .persistbss (0xC4000000
+(0x00020000)+(0x00020000)+(0x00004000))(NOLOAD) : { . = .;
*(.persistbss*) } > persistram :NONE
    . = ALIGN(4); _end = .; PROVIDE (end = .);
}



ELF Header:
  Magic:   7f 45 4c 46 01 01 01 61 00 00 00 00 00 00 00 00 
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            ARM
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           ARM
  Version:                           0x1
  Entry point address:               0x45140
  Start of program headers:          52 (bytes into file)
  Start of section headers:          304120 (bytes into file)
  Flags:                             0x2, has entry point, GNU EABI
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         3
  Size of section headers:           40 (bytes)
  Number of section headers:         30
  Section header string table index: 27

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg
Lk Inf Al
  [ 0]                   NULL            00000000 000000 000000 00     
0   0  0
  [ 1] .debug_aranges    PROGBITS        00000000 022d40 000778 00     
0   0  1
  [ 2] .debug_pubnames   PROGBITS        00000000 0234b8 000ac7 00     
0   0  1
  [ 3] .debug_info       PROGBITS        00000000 023f7f 00cad6 00     
0   0  1
  [ 4] .debug_abbrev     PROGBITS        00000000 030a55 002425 00     
0   0  1
  [ 5] .debug_line       PROGBITS        00000000 032e7a 00790b 00     
0   0  1
  [ 6] .debug_frame      PROGBITS        00000000 03a788 001148 00     
0   0  4
  [ 7] .debug_str        PROGBITS        00000000 03b8d0 0026ef 01  MS 
0   0  1
  [ 8] .fixed_vectors    PROGBITS        00000020 03dfc0 000140 00     
0   0 32
  [ 9] .page_tables      PROGBITS        00004000 03e100 00c000 00     
0   0  1
  [10] .flash_config     PROGBITS        00010000 04a100 000000 00   W 
0   0  1
  [11] .hdrs             PROGBITS        00045000 04a100 000094 00   W 
0   0  1
  [12] .hdrs.chksum      PROGBITS        00045094 005094 00006c 00  WA 
0   0  1
  [13] .rom_vectors      PROGBITS        00045100 005100 000040 00  AX 
0   0  1
  [14] .text             PROGBITS        00045140 005140 0040cc 00  AX 
0   0  4
  [15] .fini             PROGBITS        0004920c 04a194 000000 00   W 
0   0  1
  [16] .rodata           PROGBITS        0004920c 00920c 000514 00   A 
0   0  4
  [17] .rodata1          PROGBITS        00049720 04a194 000000 00   W 
0   0  1
  [18] .fixup            PROGBITS        00049720 04a194 000000 00   W 
0   0  1
  [19] .gcc_except_table PROGBITS        00049720 04a194 000000 00   W 
0   0  1
  [20] .text.chksum      PROGBITS        00049720 009720 000004 00  WA 
0   0  1
  [21] .data             PROGBITS        0004a000 00a000 018d3c 00 WAX 
0   0  4
  [22] .data.chksum      PROGBITS        00062d3c 022d3c 000004 00  WA 
0   0  1
  [23] .bss              NOBITS          00062d40 022d40 00815c 00  WA 
0   0 32
  [24] .securebss        PROGBITS        c4040000 04a194 000000 00   W 
0   0  1
  [25] .persistbss       PROGBITS        c4044000 04a194 000000 00   W 
0   0  1
  [26] .debug_ranges     PROGBITS        00000000 04a194 000120 00     
0   0  1
  [27] .shstrtab         STRTAB          00000000 04a2b4 000142 00     
0   0  1
  [28] .symtab           SYMTAB          00000000 04a8a8 001630 10    
29  e7  4
  [29] .strtab           STRTAB          00000000 04bed8 0017b6 00     
0   0  1
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings)
  I (info), L (link order), G (group), x (unknown)
  O (extra OS processing required) o (OS specific), p (processor
specific)

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg
Align
  LOAD           0x000000 0x00040000 0x00040000 0x05100 0x05100 R  
0x8000
  LOAD           0x005100 0x00045100 0x00045100 0x04624 0x04624 R E
0x8000
  LOAD           0x00a000 0x0004a000 0x0004a000 0x18d40 0x20e9c RWE
0x8000

 Section to Segment mapping:
  Segment Sections...
   00     .hdrs.chksum 
   01     .rom_vectors .text .rodata .text.chksum 
   02     .data .data.chksum .bss 




-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


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