https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115937
Bug ID: 115937 Summary: duplicate .plt in module's elf header Product: gcc Version: 10.3.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: ellery1016 at 163 dot com Target Milestone: --- My system: aarch64 Kernel version: linux-4.19 GCC version: 10.3.1 & 7.3.0 I changed my gcc from 7.3.0 to 10.3.1 and recompiled kernel code. After new kernel installed and rebooted, some call trace printed in dmesg as below: ``` Jul 10 15:39:59 localhost kernel: sysfs: cannot create duplicate filename '/module/virtio/sections/.plt' Jul 10 15:39:59 localhost kernel: CPU: 94 PID: 831 Comm: systemd-udevd Not tainted 4.19.90.rc1.aarch64 #1 Jul 10 15:39:59 localhost kernel: Hardware name: QEMU KVM Virtual Machine, BIOS 0.0.0 02/06/2015 Jul 10 15:39:59 localhost kernel: Call trace: Jul 10 15:39:59 localhost kernel: dump_backtrace+0x0/0x190 Jul 10 15:39:59 localhost kernel: show_stack+0x28/0x34 Jul 10 15:39:59 localhost kernel: dump_stack+0xa4/0xe8 Jul 10 15:39:59 localhost kernel: sysfs_warn_dup+0x70/0x90 Jul 10 15:39:59 localhost kernel: sysfs_add_file_mode_ns+0x19c/0x1d0 Jul 10 15:39:59 localhost kernel: create_files+0xa8/0x200 Jul 10 15:39:59 localhost kernel: internal_create_group+0x178/0x210 Jul 10 15:39:59 localhost kernel: sysfs_create_group+0x30/0x40 Jul 10 15:39:59 localhost kernel: add_sect_attrs+0x174/0x200 Jul 10 15:39:59 localhost kernel: mod_sysfs_setup+0x1e8/0x210 Jul 10 15:39:59 localhost kernel: load_module+0x46c/0x820 Jul 10 15:39:59 localhost kernel: __se_sys_finit_module+0xb8/0x120 Jul 10 15:39:59 localhost kernel: __arm64_sys_finit_module+0x28/0x34 Jul 10 15:39:59 localhost kernel: el0_svc_common+0x7c/0x134 Jul 10 15:39:59 localhost kernel: el0_svc_handler+0x3c/0x7c Jul 10 15:39:59 localhost kernel: el0_svc+0x8/0x1f8 ``` In fact, it seemed that all kernel modules met the problem "cannot create duplicate filename .plt",which causes directory "sections" doesn't exist any more under /sys/modules/.Meanwhile all the modules installed successfully,and the system works fine so far. As a test, I wrote a simple module like: ``` #include <linux/init.h> #include <linux/module.h> #include <linux/string.h> MODULE_LICENSE("GPL"); MODULE_VERSION("1.0"); MODULE_AUTHOR("qink"); MODULE_DESCRIPTION("Test elf plt"); static __init int test_plt_init(void) { printk("Inset a new test module.\n"); return 0; } static __exit void test_plt_exit(void) { printk("New test module exits.\n"); } module_init(test_plt_init); module_exit(test_plt_exit); ``` My makefile is like: ``` obj-m :=test_plt.o KDIR := /lib/modules/$(shell uname -r)/build PWD :=$(shell pwd) modules : $(MAKE) -C $(KDIR) M=$(PWD) modules clean : rm -f *.o .*.cmd *.symvers ``` And I compiled with gcc 10.3.1 and insmod it, the same message showed again, while I did the same thing on a gcc 7.3.0 system and there was no such message. Since it seemed like a problem with somthing called ".plt", I used readelf -S to see what is is. The result with module test_plt.ko compiled with gcc 7.3.0: ``` There are 37 section headers, starting at offset 0x2a910: Section Headers: [Nr] Name Type Address Offset Size EntSize Flags Link Info Align [ 0] NULL 0000000000000000 00000000 0000000000000000 0000000000000000 0 0 0 [ 1] .note.gnu.build-i NOTE 0000000000000000 00000040 0000000000000024 0000000000000000 A 0 0 4 [ 2] .text PROGBITS 0000000000000000 00000064 0000000000000000 0000000000000000 AX 0 0 1 [ 3] .init.text PROGBITS 0000000000000000 00000064 0000000000000028 0000000000000000 AX 0 0 4 [ 4] .rela.init.text RELA 0000000000000000 00017278 0000000000000060 0000000000000018 I 34 3 8 [ 5] .exit.text PROGBITS 0000000000000000 0000008c 000000000000001c 0000000000000000 AX 0 0 4 [ 6] .rela.exit.text RELA 0000000000000000 000172d8 0000000000000048 0000000000000018 I 34 5 8 [ 7] .modinfo PROGBITS 0000000000000000 000000a8 00000000000000ce 0000000000000000 A 0 0 8 [ 8] .rodata.str1.8 PROGBITS 0000000000000000 00000178 0000000000000038 0000000000000001 AMS 0 0 8 [ 9] .eh_frame PROGBITS 0000000000000000 000001b0 000000000000005c 0000000000000000 A 0 0 8 [10] .rela.eh_frame RELA 0000000000000000 00017320 0000000000000030 0000000000000018 I 34 9 8 [11] __mcount_loc PROGBITS 0000000000000000 00000210 0000000000000008 0000000000000000 A 0 0 8 [12] .rela__mcount_loc RELA 0000000000000000 00017350 0000000000000018 0000000000000018 I 34 11 8 [13] .note.Linux PROGBITS 0000000000000000 00000218 0000000000000018 0000000000000000 A 0 0 4 [14] __versions PROGBITS 0000000000000000 00000230 00000000000000c0 0000000000000000 A 0 0 8 [15] .data PROGBITS 0000000000000000 000002f0 0000000000000000 0000000000000000 WA 0 0 1 [16] .gnu.linkonce.thi PROGBITS 0000000000000000 00000300 0000000000000380 0000000000000000 WA 0 0 64 [17] .rela.gnu.linkonc RELA 0000000000000000 00017368 0000000000000030 0000000000000018 I 34 16 8 [18] .plt NOBITS 0000000000000380 00000680 0000000000000001 0000000000000000 WA 0 0 1 [19] .init.plt NOBITS 0000000000000381 00000680 0000000000000001 0000000000000000 WA 0 0 1 [20] .text.ftrace_tram NOBITS 0000000000000382 00000680 0000000000000001 0000000000000000 WA 0 0 1 [21] .bss NOBITS 0000000000000000 00000680 0000000000000000 0000000000000000 WA 0 0 1 [22] .debug_info PROGBITS 0000000000000000 00000680 000000000000bb4a 0000000000000000 0 0 1 [23] .rela.debug_info RELA 0000000000000000 00017398 0000000000013320 0000000000000018 I 34 22 8 [24] .debug_abbrev PROGBITS 0000000000000000 0000c1ca 0000000000000900 0000000000000000 0 0 1 [25] .debug_aranges PROGBITS 0000000000000000 0000caca 0000000000000060 0000000000000000 0 0 1 [26] .rela.debug_arang RELA 0000000000000000 0002a6b8 0000000000000060 0000000000000018 I 34 25 8 [27] .debug_ranges PROGBITS 0000000000000000 0000cb2a 0000000000000030 0000000000000000 0 0 1 [28] .rela.debug_range RELA 0000000000000000 0002a718 0000000000000060 0000000000000018 I 34 27 8 [29] .debug_line PROGBITS 0000000000000000 0000cb5a 0000000000000c5f 0000000000000000 0 0 1 [30] .rela.debug_line RELA 0000000000000000 0002a778 0000000000000030 0000000000000018 I 34 29 8 [31] .debug_str PROGBITS 0000000000000000 0000d7b9 0000000000009478 0000000000000001 MS 0 0 1 [32] .comment PROGBITS 0000000000000000 00016c31 0000000000000024 0000000000000001 MS 0 0 1 [33] .note.GNU-stack PROGBITS 0000000000000000 00016c55 0000000000000000 0000000000000000 0 0 1 [34] .symtab SYMTAB 0000000000000000 00016c58 00000000000004e0 0000000000000018 35 47 8 [35] .strtab STRTAB 0000000000000000 00017138 0000000000000139 0000000000000000 0 0 1 [36] .shstrtab STRTAB 0000000000000000 0002a7a8 0000000000000165 0000000000000000 0 0 1 Key to Flags: W (write), A (alloc), X (execute), M (merge), S (strings), I (info), L (link order), O (extra OS processing required), G (group), T (TLS), C (compressed), x (unknown), o (OS specific), E (exclude), p (processor specific) ``` The result with module test_plt.ko compiled with gcc 10.3.1: ``` There are 39 section headers, starting at offset 0xb8f0: Section Headers: [Nr] Name Type Address Offset Size EntSize Flags Link Info Align [ 0] NULL 0000000000000000 00000000 0000000000000000 0000000000000000 0 0 0 [ 1] .note.gnu.bu[...] NOTE 0000000000000000 00000040 0000000000000024 0000000000000000 A 0 0 4 [ 2] .note.Linux NOTE 0000000000000000 00000064 0000000000000018 0000000000000000 A 0 0 4 [ 3] .text PROGBITS 0000000000000000 0000007c 0000000000000000 0000000000000000 AX 0 0 1 [ 4] .init.text PROGBITS 0000000000000000 0000007c 000000000000002c 0000000000000000 AX 0 0 4 [ 5] .rela.init.text RELA 0000000000000000 00006b48 0000000000000060 0000000000000018 I 36 4 8 [ 6] .exit.text PROGBITS 0000000000000000 000000a8 000000000000001c 0000000000000000 AX 0 0 4 [ 7] .rela.exit.text RELA 0000000000000000 00006ba8 0000000000000048 0000000000000018 I 36 6 8 [ 8] .plt PROGBITS 0000000000000000 000000c4 0000000000000001 0000000000000000 AX 0 0 1 [ 9] .rodata.str1.8 PROGBITS 0000000000000000 000000c8 0000000000000038 0000000000000001 AMS 0 0 8 [10] .modinfo PROGBITS 0000000000000000 00000100 00000000000000d2 0000000000000000 A 0 0 8 [11] .eh_frame PROGBITS 0000000000000000 000001d8 0000000000000054 0000000000000000 A 0 0 8 [12] .rela.eh_frame RELA 0000000000000000 00006bf0 0000000000000030 0000000000000018 I 36 11 8 [13] __mcount_loc PROGBITS 0000000000000000 00000230 0000000000000008 0000000000000000 A 0 0 8 [14] .rela__mcount_loc RELA 0000000000000000 00006c20 0000000000000018 0000000000000018 I 36 13 8 [15] __versions PROGBITS 0000000000000000 00000238 00000000000000c0 0000000000000000 A 0 0 8 [16] .data PROGBITS 0000000000000000 000002f8 0000000000000000 0000000000000000 WA 0 0 1 [17] .gnu.linkonc[...] PROGBITS 0000000000000000 00000300 0000000000000380 0000000000000000 WA 0 0 64 [18] .rela.gnu.li[...] RELA 0000000000000000 00006c38 0000000000000030 0000000000000018 I 36 17 8 [19] .plt.idx PROGBITS 0000000000000380 00000680 0000000000000001 0000000000000000 A 0 0 1 [20] .plt PROGBITS 0000000000000381 00000681 0000000000000001 0000000000000000 AX 0 0 1 [21] .init.plt NOBITS 0000000000000382 00000682 0000000000000001 0000000000000000 A 0 0 1 [22] .text.ftrace[...] PROGBITS 0000000000000383 00000682 0000000000000001 0000000000000000 AX 0 0 1 [23] .bss NOBITS 0000000000000000 00000683 0000000000000000 0000000000000000 WA 0 0 1 [24] .debug_info PROGBITS 0000000000000000 00000683 0000000000002bbb 0000000000000000 0 0 1 [25] .rela.debug_info RELA 0000000000000000 00006c68 0000000000004a28 0000000000000018 I 36 24 8 [26] .debug_abbrev PROGBITS 0000000000000000 0000323e 0000000000000511 0000000000000000 0 0 1 [27] .debug_aranges PROGBITS 0000000000000000 0000374f 0000000000000060 0000000000000000 0 0 1 [28] .rela.debug_[...] RELA 0000000000000000 0000b690 0000000000000060 0000000000000018 I 36 27 8 [29] .debug_ranges PROGBITS 0000000000000000 000037af 0000000000000030 0000000000000000 0 0 1 [30] .rela.debug_[...] RELA 0000000000000000 0000b6f0 0000000000000060 0000000000000018 I 36 29 8 [31] .debug_line PROGBITS 0000000000000000 000037df 0000000000000448 0000000000000000 0 0 1 [32] .rela.debug_line RELA 0000000000000000 0000b750 0000000000000030 0000000000000018 I 36 31 8 [33] .debug_str PROGBITS 0000000000000000 00003c27 00000000000028a9 0000000000000001 MS 0 0 1 [34] .comment PROGBITS 0000000000000000 000064d0 0000000000000026 0000000000000001 MS 0 0 1 [35] .note.GNU-stack PROGBITS 0000000000000000 000064f6 0000000000000000 0000000000000000 0 0 1 [36] .symtab SYMTAB 0000000000000000 000064f8 0000000000000510 0000000000000018 37 49 8 [37] .strtab STRTAB 0000000000000000 00006a08 0000000000000139 0000000000000000 0 0 1 [38] .shstrtab STRTAB 0000000000000000 0000b780 000000000000016e 0000000000000000 0 0 1 Key to Flags: W (write), A (alloc), X (execute), M (merge), S (strings), I (info), L (link order), O (extra OS processing required), G (group), T (TLS), C (compressed), x (unknown), o (OS specific), E (exclude), D (mbind), p (processor specific) ``` It does show that .plt becomes two, I suppose this is the reason why kernel detect multi .plt in load_module and remove directory "sections". My gcc version for 7.3.0: ``` Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/libexec/gcc/aarch64-linux-gnu/7.3.0/lto-wrapper Target: aarch64-linux-gnu Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,fortran,lto --enable-plugin --enable-initfini-array --disable-libgcj --without-isl --without-cloog --enable-gnu-indirect-function --build=aarch64-linux-gnu --with-stage1-ldflags=' -Wl,-z,relro,-z,now' --with-boot-ldflags=' -Wl,-z,relro,-z,now' --with-multilib-list=lp64 Thread model: posix gcc version 7.3.0 (GCC) ``` gcc version for 10.3.1: ``` Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/libexec/gcc/aarch64-linux-gnu/10.3.1/lto-wrapper Target: aarch64-linux-gnu Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,fortran,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl --without-cloog --enable-gnu-indirect-function --build=aarch64-linux-gnu --with-stage1-ldflags=' -Wl,-z,relro,-z,now' --with-boot-ldflags=' -Wl,-z,relro,-z,now' --disable-bootstrap --with-multilib-list=lp64 --enable-bolt Thread model: posix Supported LTO compression algorithms: zlib gcc version 10.3.1 (GCC) ``` Now I wonder that does this matter with gcc? Is there any gcc option I can use to avoid it? What are the effects if "sections" doesn't exist under /sys/modules?