All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] efi_loader: make .data section of *_efi.so files RW
@ 2023-01-04 22:43 Heinrich Schuchardt
  2023-01-05  9:12 ` Ilias Apalodimas
  0 siblings, 1 reply; 4+ messages in thread
From: Heinrich Schuchardt @ 2023-01-04 22:43 UTC (permalink / raw)
  To: Ilias Apalodimas; +Cc: u-boot, Heinrich Schuchardt

When building with binutils 2.39 warnings

    *_efi.so has a LOAD segment with RWX permissions

occur.

Use SHF_WRITE | SHF_ALLOC as section flags for the .data section.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
 arch/arm/lib/elf_aarch64_efi.lds | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/arch/arm/lib/elf_aarch64_efi.lds b/arch/arm/lib/elf_aarch64_efi.lds
index ffc6f6e604..3e3da47d6a 100644
--- a/arch/arm/lib/elf_aarch64_efi.lds
+++ b/arch/arm/lib/elf_aarch64_efi.lds
@@ -7,6 +7,12 @@
 
 OUTPUT_FORMAT("elf64-littleaarch64", "elf64-littleaarch64", "elf64-littleaarch64")
 OUTPUT_ARCH(aarch64)
+
+PHDRS
+{
+	data PT_LOAD FLAGS(3); /* SHF_WRITE | SHF_ALLOC */
+}
+
 ENTRY(_start)
 SECTIONS
 {
@@ -49,7 +55,7 @@ SECTIONS
 		. = ALIGN(512);
 		_bss_end = .;
 		_edata = .;
-	}
+	} :data
 	_data_size = _edata - _data;
 	.rela.dyn : { *(.rela.dyn) }
 	.rela.plt : { *(.rela.plt) }
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] efi_loader: make .data section of *_efi.so files RW
  2023-01-04 22:43 [PATCH 1/1] efi_loader: make .data section of *_efi.so files RW Heinrich Schuchardt
@ 2023-01-05  9:12 ` Ilias Apalodimas
  2023-01-05  9:59   ` Heinrich Schuchardt
  0 siblings, 1 reply; 4+ messages in thread
From: Ilias Apalodimas @ 2023-01-05  9:12 UTC (permalink / raw)
  To: Heinrich Schuchardt; +Cc: u-boot

Hi Heinrich 

On Wed, Jan 04, 2023 at 11:43:08PM +0100, Heinrich Schuchardt wrote:
> When building with binutils 2.39 warnings
> 
>     *_efi.so has a LOAD segment with RWX permissions
> 
> occur.
> 
> Use SHF_WRITE | SHF_ALLOC as section flags for the .data section.
> 
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> ---
>  arch/arm/lib/elf_aarch64_efi.lds | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/lib/elf_aarch64_efi.lds b/arch/arm/lib/elf_aarch64_efi.lds
> index ffc6f6e604..3e3da47d6a 100644
> --- a/arch/arm/lib/elf_aarch64_efi.lds
> +++ b/arch/arm/lib/elf_aarch64_efi.lds
> @@ -7,6 +7,12 @@
>  
>  OUTPUT_FORMAT("elf64-littleaarch64", "elf64-littleaarch64", "elf64-littleaarch64")
>  OUTPUT_ARCH(aarch64)
> +
> +PHDRS
> +{
> +	data PT_LOAD FLAGS(3); /* SHF_WRITE | SHF_ALLOC */
> +}
> +
>  ENTRY(_start)
>  SECTIONS
>  {
> @@ -49,7 +55,7 @@ SECTIONS
>  		. = ALIGN(512);
>  		_bss_end = .;
>  		_edata = .;
> -	}
> +	} :data

Is this only to signal the end of the .data section?  If so let's get rid
of it since no other section has that 

>  	_data_size = _edata - _data;
>  	.rela.dyn : { *(.rela.dyn) }
>  	.rela.plt : { *(.rela.plt) }
> -- 
> 2.37.2
> 

other than that 
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] efi_loader: make .data section of *_efi.so files RW
  2023-01-05  9:12 ` Ilias Apalodimas
@ 2023-01-05  9:59   ` Heinrich Schuchardt
  2023-01-05 12:19     ` Heinrich Schuchardt
  0 siblings, 1 reply; 4+ messages in thread
From: Heinrich Schuchardt @ 2023-01-05  9:59 UTC (permalink / raw)
  To: Ilias Apalodimas; +Cc: u-boot

On 1/5/23 10:12, Ilias Apalodimas wrote:
> Hi Heinrich
> 
> On Wed, Jan 04, 2023 at 11:43:08PM +0100, Heinrich Schuchardt wrote:
>> When building with binutils 2.39 warnings
>>
>>      *_efi.so has a LOAD segment with RWX permissions
>>
>> occur.
>>
>> Use SHF_WRITE | SHF_ALLOC as section flags for the .data section.
>>
>> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
>> ---
>>   arch/arm/lib/elf_aarch64_efi.lds | 8 +++++++-
>>   1 file changed, 7 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/arm/lib/elf_aarch64_efi.lds b/arch/arm/lib/elf_aarch64_efi.lds
>> index ffc6f6e604..3e3da47d6a 100644
>> --- a/arch/arm/lib/elf_aarch64_efi.lds
>> +++ b/arch/arm/lib/elf_aarch64_efi.lds
>> @@ -7,6 +7,12 @@
>>   
>>   OUTPUT_FORMAT("elf64-littleaarch64", "elf64-littleaarch64", "elf64-littleaarch64")
>>   OUTPUT_ARCH(aarch64)
>> +
>> +PHDRS
>> +{
>> +	data PT_LOAD FLAGS(3); /* SHF_WRITE | SHF_ALLOC */
>> +}
>> +
>>   ENTRY(_start)
>>   SECTIONS
>>   {
>> @@ -49,7 +55,7 @@ SECTIONS
>>   		. = ALIGN(512);
>>   		_bss_end = .;
>>   		_edata = .;
>> -	}
>> +	} :data
> 
> Is this only to signal the end of the .data section?  If so let's get rid
> of it since no other section has that

:data is the reference to PHDRS entry data.

Best regards

Heinrich

> 
>>   	_data_size = _edata - _data;
>>   	.rela.dyn : { *(.rela.dyn) }
>>   	.rela.plt : { *(.rela.plt) }
>> -- 
>> 2.37.2
>>
> 
> other than that
> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] efi_loader: make .data section of *_efi.so files RW
  2023-01-05  9:59   ` Heinrich Schuchardt
@ 2023-01-05 12:19     ` Heinrich Schuchardt
  0 siblings, 0 replies; 4+ messages in thread
From: Heinrich Schuchardt @ 2023-01-05 12:19 UTC (permalink / raw)
  To: Ilias Apalodimas; +Cc: u-boot

On 1/5/23 10:59, Heinrich Schuchardt wrote:
> On 1/5/23 10:12, Ilias Apalodimas wrote:
>> Hi Heinrich
>>
>> On Wed, Jan 04, 2023 at 11:43:08PM +0100, Heinrich Schuchardt wrote:
>>> When building with binutils 2.39 warnings
>>>
>>>      *_efi.so has a LOAD segment with RWX permissions
>>>
>>> occur.
>>>
>>> Use SHF_WRITE | SHF_ALLOC as section flags for the .data section.
>>>
>>> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
>>> ---
>>>   arch/arm/lib/elf_aarch64_efi.lds | 8 +++++++-
>>>   1 file changed, 7 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/arch/arm/lib/elf_aarch64_efi.lds 
>>> b/arch/arm/lib/elf_aarch64_efi.lds
>>> index ffc6f6e604..3e3da47d6a 100644
>>> --- a/arch/arm/lib/elf_aarch64_efi.lds
>>> +++ b/arch/arm/lib/elf_aarch64_efi.lds
>>> @@ -7,6 +7,12 @@
>>>   OUTPUT_FORMAT("elf64-littleaarch64", "elf64-littleaarch64", 
>>> "elf64-littleaarch64")
>>>   OUTPUT_ARCH(aarch64)
>>> +
>>> +PHDRS
>>> +{
>>> +    data PT_LOAD FLAGS(3); /* SHF_WRITE | SHF_ALLOC */
>>> +}
>>> +
>>>   ENTRY(_start)
>>>   SECTIONS
>>>   {
>>> @@ -49,7 +55,7 @@ SECTIONS
>>>           . = ALIGN(512);
>>>           _bss_end = .;
>>>           _edata = .;
>>> -    }
>>> +    } :data
>>
>> Is this only to signal the end of the .data section?  If so let's get rid
>> of it since no other section has that
> 
> :data is the reference to PHDRS entry data.
> 
> Best regards
> 
> Heinrich
> 
>>
>>>       _data_size = _edata - _data;
>>>       .rela.dyn : { *(.rela.dyn) }
>>>       .rela.plt : { *(.rela.plt) }
>>> -- 
>>> 2.37.2
>>>
>>
>> other than that
>> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
>>
> 

As Benjamin Herrenschmidt pointed out aligning sections on 64KiB 
boundaries would be an alternative way of silencing the linker's RWX 
warnings. But I would not want helloworld.efi to be 128 KiB large.

Best regards

Heinrich

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-01-05 12:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-04 22:43 [PATCH 1/1] efi_loader: make .data section of *_efi.so files RW Heinrich Schuchardt
2023-01-05  9:12 ` Ilias Apalodimas
2023-01-05  9:59   ` Heinrich Schuchardt
2023-01-05 12:19     ` Heinrich Schuchardt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.