How to make section physical address to zero in GCC elf file?

0

Currently I am working on PowerPC target with GCC and Greenhills compiler, I found the Greenhills compiler can always generate sections with all zero pyhsical address of sections in elf, Here is sample link command file for Greenhills compiler :

MEMORY {
 RESETWORD   : org = 0x00f8c000, len = 0x00000020
 ROM1        : org = 0x09000040, len = 0x00000FC0
}
SECTIONS {    
 .resetword                    NOCHECKSUM : > RESETWORD    
 .startup                        ALIGN(4) : > ROM1
} 

I created a similar linker command file for GCC:

MEMORY {
 RESETWORD   : ORIGIN = 0x00f8c000, LENGTH = 0x00000020
 ROM1        : ORIGIN = 0x09000040, LENGTH = 0x00000FC0
}
SECTIONS
{
    .resetword : {
        *(.resetword )
    } > RESETWORD  

    .startup :  ALIGN(4){
        *(.startup)
    } > ROM1
}

After I generate the ELF file, I found the ELF file generated by Greenhills shows the Program Headers:

  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  LOAD           0x000960 0x09000040 0x00000000 0x001b8 0x001b8 R E 0x4

the section header:

  [ 1] .startup          PROGBITS        09000040 000960 0001b8 00 AXV  0   0  4

the physaddr is zero. but the GCC one is

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  LOAD           0x010040 0x09000040 0x09000040 0x001b8 0x001b8 R E 0x10000

the section header:

  [ 1] .startup          PROGBITS        09000040 010040 0001b8 00 AXV  0   0  4

I understand that the ELF has LMA(PhysAddr) and VMA(VirtAddr) and the ELF standard doesn't depends on the compiler, why the greenhills can generate the physical address with zero? how can I do that same thing in GCC?

gcc
linker
ld
linker-scripts
asked on Stack Overflow May 19, 2020 by Daniel

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0