[llvm-dev] [MC][ELF] Error for sh_type, sh_flags or sh_entsize change
Fangrui Song via llvm-dev
llvm-dev at lists.llvm.org
Thu Feb 20 12:13:57 PST 2020
This email is a heads-up that I intend to teach the integrated assembler
(in MC) to emit an error when section type/flags/entsize is changed.
This is currently silently ignored and can hide bugs.
https://reviews.llvm.org/D73999 should only affect assembly files.
.section .foo,"ax", at progbits
.section .foo,"a", at progbits # error: changed section flags for .foo, expected: 0x6
(A future improvement is to issue symbolic output: "ax")
.section .bar,"aw", at progbits
.section .bar,"aw", at nobits # error: changed section type for .bar, expected: 0x1
GNU as has had such warnings since 2000. After discussing with them recently, Alan Modra made a change upgrading most
warnings to an error (https://sourceware.org/ml/binutils/2020-02/msg00129.html).
GNU as<=2.34 # Warning: ignoring changed section attributes for .foo
GNU as>2.34 # Error: ignoring changed section attributes for .foo
Some cases remain warnings for legacy reasons:
.section .init_array,"ax", at progbits
.section .init_array,"ax", at init_array
a.s:1: Warning: ignoring incorrect section type for .init_array
a.s:1: Warning: setting incorrect section attributes for .init_array
# Some obscure sh_flags changes (OS/Processor specific flags) also remain warnings.
https://reviews.llvm.org/D73999 will simply treat all cases as errors,
which means the assembly type error can break the build (errors suppress
output). Code (not written carefully) never tested with GNU as may have problems, but I
hope they are very rare. If the error indeed causes trouble, we can
consider downgrade the sh_type error to a warning.
More information about the llvm-dev
mailing list