[PATCH v1] GAS: Keep symbols in their own section [PR27566]
Xiao Zeng
zengxiao@eswincomputing.com
Wed Oct 23 07:04:27 GMT 2024
2024-10-23 14:45 Xiao Zeng <zengxiao@eswincomputing.com> wrote:
>
>2024-10-23 12:43 Alan Modra <amodra@gmail.com> wrote:
>>
>>On Tue, Oct 22, 2024 at 05:43:18PM +0800, Xiao Zeng wrote:
>>> PR27566 is categorized under ld:
>>> <https://sourceware.org/bugzilla/show_bug.cgi?id=27566>
>>> but the root cause of this issue is in gas.
>>>
>>> The following assembly example is provided:
>>> .section .rodata
>>> .globl Sym
>>> .type Sym, @object
>>> .set Sym, . + 0x1200
>>> .size Sym, 8
>>>
>>> readelf reads ELF information:
>>> Section Headers:
>>> [Nr] Name Type Address Off Size ES Flg Lk Inf Al
>>> [ 4] .rodata PROGBITS 0000000000000000 000040 000000 00 A 0 0 1
>>>
>>> Symbol table '.symtab' contains 7 entries:
>>> Num: Value Size Type Bind Vis Ndx Name
>>> 6: 0000000000001200 8 OBJECT GLOBAL DEFAULT 4 Sym
>>>
>>> The Sym belongs to the .rodata section, but the size of .rodata is 0.
>>
>>It is not unreasonable to define a symbol relative to some section
>>with a value outside of the section. Automatically extending a
>>section to enclose a symbol should only happen in special cases.
>>Patch rejected.
>>
>>--
>>Alan Modra
>
>Dear maintainer, thank you for your reply. I think I should provide more detailed information:
>The test case <abs-run.c> is in:
><https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/abs-run.c;h=f3be58ec4938e1ae8b125da3e6796f8e448b04df;hb=ee030b28004eade3da872e7ae62a526a2940a705>
>
>1 Compilation command:
>riscv64-unknown-elf-gcc \
>-fno-schedule-insns -mcmodel=medlow -march=rv64gcv_zvfh -mabi=lp64d \
>-O3 -mrvv-max-lmul=m4 -mrvv-vector-bits=zvl -ffast-math \
>-fdata-sections abs-run.c -S -o abs-run.c.upstream.s
>
The key assembly information is:
.section .rodata
.align 3
.set .LANCHOR0,. + 0
.set .LANCHOR1,. + 4096
>Compiler version information:
>Supported LTO compression algorithms: zlib
>gcc version 15.0.0 20240912 (experimental) (g3f212eabbba-dirty)
>
>2 Assembly command:
>riscv64-unknown-elf-as abs-run.c.upstream.s -o abs-run.c.upstream.s.o
>
>3 readelf outputs the information:
>riscv64-unknown-elf-readelf -SsW abs-run.c.upstream.o > abs-run.c.upstream.o.txt
>
>Section Headers:
> [Nr] Name Type Address Off Size ES Flg Lk Inf Al
> [ 9] .rodata PROGBITS 0000000000000000 000c78 000d80 00 A 0 0 8
>
>Symbol table '.symtab' contains 110 entries:
> Num: Value Size Type Bind Vis Ndx Name
> 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
> 1: 0000000000000000 0 FILE LOCAL DEFAULT ABS abs-run.c
> 12: 0000000000000000 0 NOTYPE LOCAL DEFAULT 9 .LANCHOR0
> 13: 0000000000001000 0 NOTYPE LOCAL DEFAULT 9 .LANCHOR1
>
>This situation, where a symbol is in a section but the section's size is insufficient to contain the symbol, does exist.
>
>Thanks
>Xiao Zeng
>
Thanks
Xiao Zeng
More information about the Binutils
mailing list