On Thu, Feb 25, 2021 at 02:10:06PM +1100, Daniel Axtens wrote: > The assembler really does not like us reassigning things to the same > label: > > <instantiation>:7:9: error: invalid reassignment of non-absolute variable > 'fs_label' > > This happens across a bunch of platforms: > https://github.com/ClangBuiltLinux/linux/issues/1043 > https://github.com/ClangBuiltLinux/linux/issues/1008 > https://github.com/ClangBuiltLinux/linux/issues/920 > https://github.com/ClangBuiltLinux/linux/issues/1050 > > There is no hope of getting this fixed in LLVM, so if we want to build > with LLVM_IAS, we need to hack around it ourselves. > > For us the big problem comes from this: > > \#define USE_FIXED_SECTION(sname) \ > fs_label = start_##sname; \ > fs_start = sname##_start; \ > use_ftsec sname; > > \#define USE_TEXT_SECTION() > fs_label = start_text; \ > fs_start = text_start; \ > .text > > and in particular fs_label.
The "Setting Symbols" super short chapter reads: "A symbol can be given an arbitrary value by writing a symbol, followed by an equals sign '=', followed by an expression. This is equivalent to using the '.set' directive." And ".set" has "Set the value of SYMBOL to EXPRESSION. This changes SYMBOL's value and type to conform to EXPRESSION. If SYMBOL was flagged as external, it remains flagged. You may '.set' a symbol many times in the same assembly provided that the values given to the symbol are constants. Values that are based on expressions involving other symbols are allowed, but some targets may restrict this to only being done once per assembly. This is because those targets do not set the addresses of symbols at assembly time, but rather delay the assignment until a final link is performed. This allows the linker a chance to change the code in the files, changing the location of, and the relative distance between, various different symbols. If you '.set' a global symbol, the value stored in the object file is the last value stored into it." So this really should be fixed in clang: it is basic assembler syntax. Segher