Patch "modpost: fix section mismatch message for RELA" has been added to the 6.6-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    modpost: fix section mismatch message for RELA

to the 6.6-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     modpost-fix-section-mismatch-message-for-rela.patch
and it can be found in the queue-6.6 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit b1169cd7e4b056f65ef6562bd70b52752cac97cf
Author: Masahiro Yamada <masahiroy@xxxxxxxxxx>
Date:   Wed Nov 1 02:46:27 2023 +0900

    modpost: fix section mismatch message for RELA
    
    [ Upstream commit 1c4a7587d1bbee0fd53b63af60e4244a62775f57 ]
    
    The section mismatch check prints a bogus symbol name on some
    architectures.
    
    [test code]
    
      #include <linux/init.h>
    
      int __initdata foo;
      int get_foo(void) { return foo; }
    
    If you compile it with GCC for riscv or loongarch, modpost will show an
    incorrect symbol name:
    
      WARNING: modpost: vmlinux: section mismatch in reference: get_foo+0x8 (section: .text) -> done (section: .init.data)
    
    To get the correct symbol address, the st_value must be added.
    
    This issue has never been noticed since commit 93684d3b8062 ("kbuild:
    include symbol names in section mismatch warnings") presumably because
    st_value becomes zero on most architectures when the referenced symbol
    is looked up. It is not true for riscv or loongarch, at least.
    
    With this fix, modpost will show the correct symbol name:
    
      WARNING: modpost: vmlinux: section mismatch in reference: get_foo+0x8 (section: .text) -> foo (section: .init.data)
    
    Signed-off-by: Masahiro Yamada <masahiroy@xxxxxxxxxx>
    Reviewed-by: Nick Desaulniers <ndesaulniers@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index b3dee80497cb2..ac4ef3e206bbd 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -1496,13 +1496,15 @@ static void section_rela(struct module *mod, struct elf_info *elf,
 		return;
 
 	for (rela = start; rela < stop; rela++) {
+		Elf_Sym *tsym;
 		Elf_Addr taddr, r_offset;
 		unsigned int r_type, r_sym;
 
 		r_offset = TO_NATIVE(rela->r_offset);
 		get_rel_type_and_sym(elf, rela->r_info, &r_type, &r_sym);
 
-		taddr = TO_NATIVE(rela->r_addend);
+		tsym = elf->symtab_start + r_sym;
+		taddr = tsym->st_value + TO_NATIVE(rela->r_addend);
 
 		switch (elf->hdr->e_machine) {
 		case EM_RISCV:
@@ -1517,7 +1519,7 @@ static void section_rela(struct module *mod, struct elf_info *elf,
 			break;
 		}
 
-		check_section_mismatch(mod, elf, elf->symtab_start + r_sym,
+		check_section_mismatch(mod, elf, tsym,
 				       fsecndx, fromsec, r_offset, taddr);
 	}
 }



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux