]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
objtool: Fix elf_create_undef_symbol() endianness
authorVasily Gorbik <gor@linux.ibm.com>
Wed, 12 May 2021 17:42:10 +0000 (19:42 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 25 Jul 2022 09:26:56 +0000 (11:26 +0200)
commit 46c7405df7de8deb97229eacebcee96d61415f3f upstream.

Currently x86 cross-compilation fails on big endian system with:

  x86_64-cross-ld: init/main.o: invalid string offset 488112128 >= 6229 for section `.strtab'

Mark new ELF data in elf_create_undef_symbol() as symbol, so that libelf
does endianness handling correctly.

Fixes: 2f2f7e47f052 ("objtool: Add elf_create_undef_symbol()")
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: https://lore.kernel.org/r/patch-1.thread-6c9df9.git-d39264656387.your-ad-here.call-01620841104-ext-2554@work.hours
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
tools/objtool/elf.c

index 0fb5b45aec53a9cb1c10254474c4405ef979eb8f..5aa3b4e76479e9082e9c5abf226a16749c86f673 100644 (file)
@@ -961,6 +961,7 @@ static int elf_add_string(struct elf *elf, struct section *strtab, char *str)
        data->d_buf = str;
        data->d_size = strlen(str) + 1;
        data->d_align = 1;
+       data->d_type = ELF_T_SYM;
 
        len = strtab->len;
        strtab->len += data->d_size;