Skip to contentSkip to conversation

powerpc/ppc4xx: add ENTRY() to linker script

PATCH New jozsef imrek 3 participants 4 messages Mar 24, 2011 – Apr 4, 2011 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc/ppc4xx: add ENTRY() to linker script

Add ENTRY() command to the linker script so that entry point is correctly marked in the final ELF file.

---
 arch/powerpc/cpu/ppc4xx/u-boot.lds |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
arch/powerpc/cpu/ppc4xx/u-boot.lds +2 -0
index 656f59a..b82e1e8 100644
@@ -38,6 +38,8 @@ PHDRS
   bss PT_LOAD;
 }
 
+ENTRY(_start)
+
 SECTIONS
 {
   /* Read-only sections, merged into text segment: */
Signature · 1 line
1.7.2.5
#1 lore raw

PATCH 1/1 powerpc/ppc4xx: add ENTRY() to linker script

Dear jozsef imrek,

Quoted 2 lines · In message <[email protected]> you wrote:

Add ENTRY() command to the linker script so that entry point is correctly marked in the final ELF file.

Which exact problem are you trying to fix?

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Honest error is to be pitied, not ridiculed.
                                       -- Philip Earl of Chesterfield
#2 lore raw

PATCH 1/1 powerpc/ppc4xx: add ENTRY() to linker script

dear wolfgang,

Quoted 4 lines · Wolfgang Denk
Quoted 2 lines

Add ENTRY() command to the linker script so that entry point is correctly marked in the final ELF file.

Which exact problem are you trying to fix?

i'm sorry, i probably should have been more verbose in the changelog.

when cross-compiling u-boot for the avnet virtex-4 minimodule (make fx12mm_config; make, with SYS_TEXT_BASE=0x02000000) i end up with a u-boot.lds linker script that has no ENTRY() command.

this will result in an incorrect ELF file: the entry point in the ELF header points to the first byte of the first loadable segment (which is ~the version string at 0x02000004: "U-Boot 2011..") instead of the first instruction to be executed at _start (at 0x02002100 in this case).

powerpc-405-linux-gnu-readelf -e u-boot:

ELF Header:
Magic: 7f 45 4c 46 01 02 01 00 00 00 00 00 00 00 00 00

  Class:                             ELF32
  Data:                              2's complement, big endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           PowerPC
  Version:                           0x1
  Entry point address:               0x2000000

..

powerpc-405-linux-gnu-objdump -d u-boot:

Disassembly of section .text:

02000000 <version_string-0x4>:
2000000: 27 05 19 56 dozi r24,r5,6486

02000004 <version_string>:

 2000004:       55 2d 42 6f     rlwinm. r13,r9,8,9,23
 2000008:       6f 74 20 32     xoris   r20,r27,8242
 200000c:       30 31 31 2e     addic   r1,r17,12590
 2000010:       30 33 2d 72     addic   r1,r19,11634
        ...

02002100 <_start>:

 2002100:       38 80 00 00     li      r4,0
 2002104:       7c 99 eb a6     mtpmc1  r4
 2002108:       7c 9a eb a6     mtdcwr  r4
 200210c:       7c 94 f3 a6     mtesr   r4
 2002110:       7c 9a f3 a6     mttcr   r4
        ...

anything trying to load and run this ELF file (eg xilinx's XMD debugger, or a bootloader stored in the FPGA fabric) will fail to do so because the processor will jump to 0x02000000 and try to execute the version string.

best regards,

Signature · 5 lines
mazsi

----------------------------------------------------------------
strawberry fields forever!                       mazsi at imrek.org
----------------------------------------------------------------
#3 lore raw

PATCH 1/1 powerpc/ppc4xx: add ENTRY() to linker script

Hi Jozsef,

Quoted 7 lines · On Friday 25 March 2011 00:54:18 jozsef imrek wrote:
Quoted 4 lines
Quoted 2 lines

Add ENTRY() command to the linker script so that entry point is correctly marked in the final ELF file.

Which exact problem are you trying to fix?

i'm sorry, i probably should have been more verbose in the changelog.

Yes. Please resend this patch as v2, with the extended commit text so that I may apply it in this merge window.

Thanks.

Cheers,
Stefan

--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: office at denx.de