From: Fangrui Song <hidden> Date: 2020-03-25 05:21:02
.globl sets the symbol binding to STB_GLOBAL while .weak sets the
binding to STB_WEAK. They should not be used together. It is accidetal
rather then intentional that GNU as let .weak override .globl while
clang integrated assembler let the last win.
Fixes: cd197ffcf10b "[POWERPC] zImage: Cleanup and improve zImage entry point"
Fixes: ee9d21b3b358 "powerpc/boot: Ensure _zimage_start is a weak symbol"
Link: https://github.com/ClangBuiltLinux/linux/issues/937
Signed-off-by: Fangrui Song <redacted>
Cc: Joel Stanley <joel@jms.id.au>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: clang-built-linux@googlegroups.com
---
arch/powerpc/boot/crt0.S | 3 ---
1 file changed, 3 deletions(-)
From: Joel Stanley <joel@jms.id.au> Date: 2020-03-25 05:24:21
On Wed, 25 Mar 2020 at 05:19, Fangrui Song [off-list ref] wrote:
quoted hunk
.globl sets the symbol binding to STB_GLOBAL while .weak sets the
binding to STB_WEAK. They should not be used together. It is accidetal
rather then intentional that GNU as let .weak override .globl while
clang integrated assembler let the last win.
Fixes: cd197ffcf10b "[POWERPC] zImage: Cleanup and improve zImage entry point"
Fixes: ee9d21b3b358 "powerpc/boot: Ensure _zimage_start is a weak symbol"
Link: https://github.com/ClangBuiltLinux/linux/issues/937
Signed-off-by: Fangrui Song <redacted>
Cc: Joel Stanley <joel@jms.id.au>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: clang-built-linux@googlegroups.com
---
arch/powerpc/boot/crt0.S | 3 ---
1 file changed, 3 deletions(-)
Your explanation makes sense to me. I've added Alan to cc for his review.
Reviewed-by: Joel Stanley <joel@jms.id.au>
Thanks for the patch.
Cheers,
Joel
From: Alan Modra <hidden> Date: 2020-03-25 08:47:16
On Wed, Mar 25, 2020 at 05:22:31AM +0000, Joel Stanley wrote:
On Wed, 25 Mar 2020 at 05:19, Fangrui Song [off-list ref] wrote:
quoted
.globl sets the symbol binding to STB_GLOBAL while .weak sets the
binding to STB_WEAK. They should not be used together. It is accidetal
rather then intentional that GNU as let .weak override .globl while
clang integrated assembler let the last win.
No, it isn't accidental. gas deliberately lets .weak override .globl.
Since 1996-07-26, git commit 5ca547dc239
I'm fine with the patch so far as it is true that there is no need for
both .globl and .weak (and it looks silly to have both), but the
explanation isn't true. The patch is needed because the clang
assembler is incompatible with gas in this detail.
quoted
Fixes: cd197ffcf10b "[POWERPC] zImage: Cleanup and improve zImage entry point"
Fixes: ee9d21b3b358 "powerpc/boot: Ensure _zimage_start is a weak symbol"
Link: https://github.com/ClangBuiltLinux/linux/issues/937
Signed-off-by: Fangrui Song <redacted>
Cc: Joel Stanley <joel@jms.id.au>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: clang-built-linux@googlegroups.com
---
arch/powerpc/boot/crt0.S | 3 ---
1 file changed, 3 deletions(-)
Your explanation makes sense to me. I've added Alan to cc for his review.
Reviewed-by: Joel Stanley <joel@jms.id.au>
Thanks for the patch.
Cheers,
Joel
From: Fangrui Song <hidden> Date: 2020-03-25 16:36:43
On 2020-03-25, Alan Modra wrote:
On Wed, Mar 25, 2020 at 05:22:31AM +0000, Joel Stanley wrote:
quoted
On Wed, 25 Mar 2020 at 05:19, Fangrui Song [off-list ref] wrote:
quoted
.globl sets the symbol binding to STB_GLOBAL while .weak sets the
binding to STB_WEAK. They should not be used together. It is accidetal
rather then intentional that GNU as let .weak override .globl while
clang integrated assembler let the last win.
No, it isn't accidental. gas deliberately lets .weak override .globl.
Since 1996-07-26, git commit 5ca547dc239
Fair. I am sadded by this commit.
% sed -n 'N;/.globl.*\n.*.weak/p;D' binutils-gdb/gas/testsuite/**/*(.)
I checked all occurrences and none is a real test excercising the behavior (.weak override .globl).
All seem accidental.
It is unclear that clang integrated assembler should copy this
behavior, though. For the record, I asked on binutils@sourceware.org
whether the assembler should error when .weak/.local can override a
previous binding directive. It was rejected
https://sourceware.org/pipermail/binutils/2020-March/110376.html
On the clang integrated assembler side, we may try building things with
an error or leave the overriding behavior as is.
I'm fine with the patch so far as it is true that there is no need for
both .globl and .weak (and it looks silly to have both), but the
explanation isn't true. The patch is needed because the clang
assembler is incompatible with gas in this detail.
Since using one of .weak|.globl is nearly well-known, I'll send PATCH v2 with
the description updated.
On 2020-03-25, Segher Boessenkool wrote:
Nothing is "overridden".
The as manual says (.weak):
This directive sets the weak attribute on the comma separated list of
symbol 'names'. If the symbols do not already exist, they will be
created.
so this behaviour is obviously as intended (or was later documented in
any case), so LLVM has a bug to fix (whether you like this (much saner)
behaviour or not).
I will probably not call this a bug. I have recently discovered other
discrepancy for which I think copying gas behaviors can just clutter up the
code. We may need our own assembler documentation at some point.
quoted
quoted
Fixes: cd197ffcf10b "[POWERPC] zImage: Cleanup and improve zImage entry point"
Fixes: ee9d21b3b358 "powerpc/boot: Ensure _zimage_start is a weak symbol"
Link: https://github.com/ClangBuiltLinux/linux/issues/937
Signed-off-by: Fangrui Song <redacted>
Cc: Joel Stanley <joel@jms.id.au>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: clang-built-linux@googlegroups.com
---
arch/powerpc/boot/crt0.S | 3 ---
1 file changed, 3 deletions(-)
Your explanation makes sense to me. I've added Alan to cc for his review.
Reviewed-by: Joel Stanley <joel@jms.id.au>
Thanks for the patch.
Cheers,
Joel
On Tue, Mar 24, 2020 at 10:18:20PM -0700, Fangrui Song wrote:
.globl sets the symbol binding to STB_GLOBAL while .weak sets the
binding to STB_WEAK. They should not be used together. It is accidetal
rather then intentional that GNU as let .weak override .globl while
clang integrated assembler let the last win.
Nothing is "overridden".
The as manual says (.weak):
This directive sets the weak attribute on the comma separated list of
symbol 'names'. If the symbols do not already exist, they will be
created.
so this behaviour is obviously as intended (or was later documented in
any case), so LLVM has a bug to fix (whether you like this (much saner)
behaviour or not).
Segher
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2020-03-25 11:12:22
Fangrui Song [off-list ref] writes:
.globl sets the symbol binding to STB_GLOBAL while .weak sets the
binding to STB_WEAK. They should not be used together. It is accidetal
rather then intentional that GNU as let .weak override .globl while
clang integrated assembler let the last win.
Fixes: cd197ffcf10b "[POWERPC] zImage: Cleanup and improve zImage entry point"
Fixes: ee9d21b3b358 "powerpc/boot: Ensure _zimage_start is a weak symbol"
Link: https://github.com/ClangBuiltLinux/linux/issues/937
Signed-off-by: Fangrui Song <redacted>
So it seems the patch is OK but people don't agree with the explanation
in the changelog.
Please send a v2 that captures the responses from Segher and Alan.
cheers