# HG changeset patch # User Paul Boddie # Date 1540676654 -7200 # Node ID b55498587c1fb42078cbf4c64fc818b61c10f032 # Parent 37efd786c13361e8ad4485c6eedc5d1d38d14702 Merged sections to avoid virtual and physical (load) address discrepancies. The .rodata objects were being positioned after the .text objects, but although the starting virtual address for the .rodata objects seemed to be aligned to a particular boundary (maybe 16 bytes), the starting physical address was not aligned. Consequently, the program was looking for objects at addresses beyond their actual, stored locations. diff -r 37efd786c133 -r b55498587c1f lib/payload.ld --- a/lib/payload.ld Sat Oct 27 23:38:27 2018 +0200 +++ b/lib/payload.ld Sat Oct 27 23:44:14 2018 +0200 @@ -34,16 +34,26 @@ .boot : { *(.boot*) } > kseg0_boot_mem AT > physical_boot_mem - /* Exception/interrupt vectors and general program code. */ + .flash : { + + /* Exception/interrupt vectors and general program code. */ - .vectors : { *(.vectors*) } > kseg0_program_mem AT > physical_program_mem + *(.vectors*) - .got : { + /* Global offset table. */ + _gp = ALIGN(16); *(.got*) - } > kseg0_program_mem AT > physical_program_mem + + /* Program code. */ + + *(.text*) - .text : { *(.text*) } > kseg0_program_mem AT > physical_program_mem + /* Store constant data in program memory. */ + + *(.rodata*) + + } > kseg0_program_mem AT > physical_program_mem /* Reserve space at the bottom of RAM for the IRQ stack. */ @@ -51,19 +61,6 @@ . += IRQ_STACK_SIZE; } > kseg0_data_mem AT > physical_data_mem - /* Add other data after the IRQ stack. */ - - .bss : { - _bss = .; - *(.bss*) - } > kseg0_data_mem AT > physical_data_mem - - _bss_size = SIZEOF(.bss); - - /* Store constant data in program memory. */ - - .rodata : { *(.rodata*) } > kseg0_program_mem AT > physical_program_mem - /* Store initialised non-constant data in program memory for relocation. Employ data memory addresses for generated content. */ @@ -75,6 +72,15 @@ _data_original = LOADADDR(.data) - ORIGIN(physical_program_mem) + ORIGIN(kseg0_program_mem); _data_size = SIZEOF(.data); + /* Reserve space for uninitialised data. */ + + .bss : { + _bss = .; + *(.bss*) + } > kseg0_data_mem AT > physical_data_mem + + _bss_size = SIZEOF(.bss); + /* Device configuration registers to be flashed. */ .devcfg0 : { *(.devcfg0) } > config0 AT > physical_config0