From: Daniel Axtens <dja@axtens•net>
To: Segher Boessenkool <segher@kernel•crashing.org>
Cc: linuxppc-dev@lists•ozlabs.org, llvmlinux@lists•linuxfoundation.org
Subject: Re: [RFC PATCH 8/8] powerpc/64/asm: don't reassign labels
Date: Fri, 26 Feb 2021 11:28:38 +1100 [thread overview]
Message-ID: <87lfbboeo9.fsf@dja-thinkpad.axtens.net> (raw)
In-Reply-To: <20210225160857.GH28121@gate.crashing.org>
Segher Boessenkool <segher@kernel•crashing.org> writes:
> 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.
No doubt I have explained this poorly.
LLVM does allow some things, this builds fine for example:
.set foo, 8192
addi %r3, %r3, foo
.set foo, 1234
addi %r3, %r3, foo
However, this does not:
a:
.set foo, a
addi %r3, %r3, foo@l
b:
.set foo, b
addi %r3, %r3, foo-a
clang -target ppc64le -integrated-as foo.s -o foo.o -c
foo.s:5:11: error: invalid reassignment of non-absolute variable 'foo' in '.set' directive
.set foo, b
^
gas otoh, has no issues with reassignment:
$ powerpc64-linux-gnu-as foo.s -c -o foo.o
$ powerpc64-linux-gnu-objdump -dr foo.o
foo.o: file format elf64-powerpc
Disassembly of section .text:
0000000000000000 <a>:
0: 38 63 00 00 addi r3,r3,0
2: R_PPC64_ADDR16_LO .text
0000000000000004 <b>:
4: 38 63 00 04 addi r3,r3,4
It seems the llvm assembler only does a single pass, so they're not keen
on trying to support reassigning labels with non-absolute values.
Kind regards,
Daniel
>
> Segher
next prev parent reply other threads:[~2021-02-26 0:29 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-25 3:09 [RFC PATCH 0/8] WIP support for the LLVM integrated assembler Daniel Axtens
2021-02-25 3:09 ` [PATCH 1/8] powerpc/64s/exception: Clean up a missed SRR specifier Daniel Axtens
2021-02-25 3:10 ` [RFC PATCH 2/8] powerpc: check for support for -Wa,-m{power4,any} Daniel Axtens
2021-03-19 1:32 ` [RFC PATCH 2/8] powerpc: check for support for -Wa, -m{power4, any} Nicholas Piggin
2021-03-19 10:53 ` Michael Ellerman
2021-02-25 3:10 ` [RFC PATCH 3/8] powerpc/head-64: do less gas-specific stuff with sections Daniel Axtens
2021-03-19 1:35 ` Nicholas Piggin
2021-02-25 3:10 ` [RFC PATCH 4/8] powerpc/ppc_asm: use plain numbers for registers Daniel Axtens
2021-02-25 15:25 ` Segher Boessenkool
2021-02-26 0:12 ` Daniel Axtens
2021-03-19 1:39 ` Nicholas Piggin
2021-02-25 3:10 ` [RFC PATCH 5/8] poweprc/lib/quad: Provide macros for lq/stq Daniel Axtens
2021-02-25 15:44 ` Segher Boessenkool
2021-02-26 0:13 ` Daniel Axtens
2021-02-25 3:10 ` [RFC PATCH 6/8] powerpc/mm/book3s64/hash: drop pre 2.06 tlbiel for clang Daniel Axtens
2021-03-19 2:01 ` Nicholas Piggin
2021-03-22 16:49 ` Christophe Leroy
2021-03-22 18:11 ` Nicholas Piggin
2021-03-24 15:51 ` Segher Boessenkool
2021-03-24 21:07 ` Segher Boessenkool
2021-02-25 3:10 ` [RFC PATCH 7/8] powerpc/purgatory: drop .machine specifier Daniel Axtens
2021-02-25 15:58 ` Segher Boessenkool
2021-02-26 0:17 ` Daniel Axtens
2021-03-19 2:05 ` Nicholas Piggin
2021-03-19 10:59 ` Michael Ellerman
2021-02-25 3:10 ` [RFC PATCH 8/8] powerpc/64/asm: don't reassign labels Daniel Axtens
2021-02-25 16:08 ` Segher Boessenkool
2021-02-26 0:28 ` Daniel Axtens [this message]
2021-03-19 2:15 ` Nicholas Piggin
2021-03-14 10:01 ` [RFC PATCH 0/8] WIP support for the LLVM integrated assembler Michael Ellerman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87lfbboeo9.fsf@dja-thinkpad.axtens.net \
--to=dja@axtens$(echo .)net \
--cc=linuxppc-dev@lists$(echo .)ozlabs.org \
--cc=llvmlinux@lists$(echo .)linuxfoundation.org \
--cc=segher@kernel$(echo .)crashing.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox