[PATCH 1/1] arm: separate .data and .text sections of EFI binaries

Heinrich Schuchardt heinrich.schuchardt at canonical.com
Sat Feb 24 10:16:53 CET 2024


On 2/16/24 11:35, Ilias Apalodimas wrote:
> Hi Heinrich,
> 
> [...]
> 
>>          }
>> +       .rela.dyn : { *(.rela.dyn) }
>> +       .rela.plt : { *(.rela.plt) }
>> +       .rela.got : { *(.rela.got) }
>> +       .rela.data : { *(.rela.data) *(.rela.data*) }
> 
> Why are we switching from Rel to Rela?

This was wrong.

Looking at the u-boot ELF binary we see these relocation sections:

arm: .rel.dyn
arm64: .rela.dyn
riscv64: .rela.dyn

In our EFI object files we currently have no relocations. This is why 
tests did not complain.

In arch/arm/lib/reloc_arm_efi.c we handle DT_REL.
In arch/arm/lib/reloc_aarch64_efi.c we handle DT_RELA.
In arch/riscv/lib/reloc_riscv_efi.c we handle DT_RELA.

Best regards

Heinrich

> 
>>          _etext = .;
>>          _text_size = . - _text;
>> -       .dynamic  : { *(.dynamic) }
>> +       . = ALIGN(4096);
>>          .data : {
>>                  _data = .;
>>                  *(.sdata)
>> @@ -47,20 +59,19 @@ SECTIONS
>>                  . = ALIGN(512);
>>                  _bss_end = .;
>>                  _edata = .;
>> -       }
>> -       .rel.dyn : { *(.rel.dyn) }
>> -       .rel.plt : { *(.rel.plt) }
>> -       .rel.got : { *(.rel.got) }
>> -       .rel.data : { *(.rel.data) *(.rel.data*) }
>> -       _data_size = . - _etext;
>> +       } :data
>> +       _data_size = _edata - _data;
>>
>> +       . = ALIGN(4096);
>> +       .dynsym   : { *(.dynsym) }
>> +       . = ALIGN(4096);
>> +       .dynstr   : { *(.dynstr) }
>> +       . = ALIGN(4096);
>> +       .note.gnu.build-id : { *(.note.gnu.build-id) }
>>          /DISCARD/ : {
>>                  *(.rel.reloc)
>>                  *(.eh_frame)
>>                  *(.note.GNU-stack)
>> -               *(.dynsym)
>> -               *(.dynstr)
>> -               *(.note.gnu.build-id)
>> -               *(.comment)
>>          }
>> +       .comment 0 : { *(.comment) }
>>   }
>> --
>> 2.43.0
>>
> 
> Cheers
> /Ilias



More information about the U-Boot mailing list