Re: CBL issue #431: lld: x86_64: sysfs: cannot create duplicate filename $module/.rodata.cst{16,32}

From: Denys Vlasenko
Date: Mon Apr 08 2019 - 09:56:13 EST


On 4/8/19 3:36 PM, Sedat Dilek wrote:
I fell over your commit "crypto: x86 - make constants readonly, allow
linker to merge them" [1] while digging into ClangBuiltLinux issue 431
[0].

I see the following in my dmesg-log:

$ grep sysfs: dmesg_5.0.4-rc1-1-amd64-cbl-asmgoto.txt
[Fri Mar 22 10:32:09 2019] sysfs: cannot create duplicate filename
'/module/usbcore/sections/.rodata.cst16'
[Fri Mar 22 10:32:18 2019] sysfs: cannot create duplicate filename
'/module/nfsd/sections/.rodata.cst32'
[Fri Mar 22 10:32:18 2019] sysfs: cannot create duplicate filename
'/module/iwlwifi/sections/.rodata.cst16'
[Fri Mar 22 10:32:18 2019] sysfs: cannot create duplicate filename
'/module/i915/sections/.rodata.cst32'
[Fri Mar 22 10:32:18 2019] sysfs: cannot create duplicate filename
'/module/mac80211/sections/.rodata.cst32'
[Fri Mar 22 10:32:18 2019] sysfs: cannot create duplicate filename
'/module/iwlmvm/sections/.rodata.cst16'
[Fri Mar 22 10:32:20 2019] sysfs: cannot create duplicate filename
'/module/bluetooth/sections/.rodata.cst16'

Above modules have dependencies to stuff from arch/x86/crypto (see below P.S.).

Not sure how exactly this causes the error, but the cause seems to be
having more than one section with the same name. This occurs in only three files
(grep for ".rodata.cst16," string):

cast6-avx-x86_64-asm_64.S
camellia-aesni-avx2-asm_64.S
camellia-aesni-avx-asm_64.S

/* NB: section is mergeable, all elements must be aligned 16-byte blocks */
.section .rodata.cst16, "aM", @progbits, 16

In other places I used .rodata.cst16.OBJECTNAME, but in these three cases
there are more than one object in the section, so I left it w/o OBJECTNAME.

I propose to change section name, append _module_ name and optionally
a comment why this is done:

/* NB: section is mergeable, all elements must be aligned 16-byte blocks */
+/* There is more than one object in this section, let's use module name
+ as unique suffix */
-.section .rodata.cst16, "aM", @progbits, 16
+.section .rodata.cst16.cast6-avx-x86_64-asm_64, "aM", @progbits, 16


Looks like LLD defaults to -ffunction-sections and -fdata-sections.
Do you happen to know what the defaults are for BFD linker?

linker does not create section names. Compiler does for .c files,
for .S files they are made by a human.