diff mbox series

[RFC,07/10] arm: efi_loader: discard hash, unwind information

Message ID 20230520205547.1009254-8-CFSworks@gmail.com
State RFC
Delegated to: Tom Rini
Headers show
Series Improve ARM target's support for LLVM toolchain | expand

Commit Message

Sam Edwards May 20, 2023, 8:55 p.m. UTC
LLD tends to put these at the very beginning of the file, only
for the .text 0x0 directive to end up going backward and
overlapping them, creating an error.

Since they don't appear to be used at runtime, just discard them.

Signed-off-by: Sam Edwards <CFSworks@gmail.com>
---

 arch/arm/lib/elf_arm_efi.lds | 3 +++
 1 file changed, 3 insertions(+)

Comments

Ilias Apalodimas May 22, 2023, 7 a.m. UTC | #1
Hi Sam

On Sat, 20 May 2023 at 23:56, Sam Edwards <cfsworks@gmail.com> wrote:
>
> LLD tends to put these at the very beginning of the file, only
> for the .text 0x0 directive to end up going backward and
> overlapping them, creating an error.
>
> Since they don't appear to be used at runtime, just discard them.
>
> Signed-off-by: Sam Edwards <CFSworks@gmail.com>
> ---
>
>  arch/arm/lib/elf_arm_efi.lds | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/arch/arm/lib/elf_arm_efi.lds b/arch/arm/lib/elf_arm_efi.lds
> index 767ebda635..0b6cc5bcb6 100644
> --- a/arch/arm/lib/elf_arm_efi.lds
> +++ b/arch/arm/lib/elf_arm_efi.lds
> @@ -62,5 +62,8 @@ SECTIONS
>                 *(.dynstr)
>                 *(.note.gnu.build-id)
>                 *(.comment)
> +               *(.hash)
> +               *(.gnu.hash)

The reason we end up with both hash and gnu.hash is because the hash
style is set to 'both'.  Should we perhaps use (and strip) only one of
them?

Thanks
/Ilias

> +               *(.ARM.exidx)
>         }
>  }
> --
> 2.39.2
>
Sam Edwards May 22, 2023, 7:25 p.m. UTC | #2
Hi Ilias,

On 5/22/23 01:00, Ilias Apalodimas wrote:
> The reason we end up with both hash and gnu.hash is because the hash
> style is set to 'both'.  Should we perhaps use (and strip) only one of
> them?

If we do keep one, it should probably be .hash -- see commit b02bfc4dfc.

I admit I'm completely mystified as to why we need the hash tables at 
all. The ELF spec says those are just for the dynamic linker, but 
neither the EFI code nor the self-relocating thunk require it, and I 
don't know of any target where the u-boot ELF itself is the shipped 
binary. For all I know, there never was a need to include .hash and 
Albert's commit fixed whatever problem he was facing only accidentally. 
Do you have any insights?

LLD's --hash-style option doesn't appear to have a "none" option or I'd 
just be making use of that here.

Cheers,
Sam
Ilias Apalodimas May 22, 2023, 8:28 p.m. UTC | #3
Hi Sam,

On Mon, 22 May 2023 at 22:25, Sam Edwards <cfsworks@gmail.com> wrote:
>
> Hi Ilias,
>
> On 5/22/23 01:00, Ilias Apalodimas wrote:
> > The reason we end up with both hash and gnu.hash is because the hash
> > style is set to 'both'.  Should we perhaps use (and strip) only one of
> > them?
>
> If we do keep one, it should probably be .hash -- see commit b02bfc4dfc.
>
> I admit I'm completely mystified as to why we need the hash tables at
> all. The ELF spec says those are just for the dynamic linker, but
> neither the EFI code nor the self-relocating thunk require it, and I
> don't know of any target where the u-boot ELF itself is the shipped
> binary.

Me neither

> For all I know, there never was a need to include .hash and
> Albert's commit fixed whatever problem he was facing only accidentally.
> Do you have any insights?

Unfortunately not.  I just started looking up the linker scripts myself.

>
> LLD's --hash-style option doesn't appear to have a "none" option or I'd
> just be making use of that here.

Indeed.  I am fine with the patch regardless, switching the makefile
to only produce one of them is a nit anyway, since we'll eventually
get rid of them

Thanks
/Ilias
>
> Cheers,
> Sam
Heinrich Schuchardt May 23, 2023, 5:08 a.m. UTC | #4
Am 22. Mai 2023 21:25:50 MESZ schrieb Sam Edwards <cfsworks@gmail.com>:
>Hi Ilias,
>
>On 5/22/23 01:00, Ilias Apalodimas wrote:
>> The reason we end up with both hash and gnu.hash is because the hash
>> style is set to 'both'.  Should we perhaps use (and strip) only one of
>> them?
>
>If we do keep one, it should probably be .hash -- see commit b02bfc4dfc.
>
>I admit I'm completely mystified as to why we need the hash tables at all. The ELF spec says those are just for the dynamic linker, but neither the EFI code nor the self-relocating thunk require it, and I don't know of any target where the u-boot ELF itself is the shipped binary. For all I know, there never was a need to include .hash and Albert's commit fixed whatever problem he was facing only accidentally. Do you have any insights?
>

Ubuntu's and Debian's u-boot-qemu package ships uboot.elf for multiple architectures. Cf. https://packages.debian.org/bullseye/all/u-boot-qemu/filelist

You can pass uboot.elf as -kernel parameter to QEMU.

Best regards

Heinrich 


>LLD's --hash-style option doesn't appear to have a "none" option or I'd just be making use of that here.
>
>Cheers,
>Sam
diff mbox series

Patch

diff --git a/arch/arm/lib/elf_arm_efi.lds b/arch/arm/lib/elf_arm_efi.lds
index 767ebda635..0b6cc5bcb6 100644
--- a/arch/arm/lib/elf_arm_efi.lds
+++ b/arch/arm/lib/elf_arm_efi.lds
@@ -62,5 +62,8 @@  SECTIONS
 		*(.dynstr)
 		*(.note.gnu.build-id)
 		*(.comment)
+		*(.hash)
+		*(.gnu.hash)
+		*(.ARM.exidx)
 	}
 }