public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Error for the second binding (.local/.weak/.globl)
@ 2020-03-25  5:36 Fangrui Song
  2020-03-25  8:41 ` Alan Modra
  0 siblings, 1 reply; 4+ messages in thread
From: Fangrui Song @ 2020-03-25  5:36 UTC (permalink / raw)
  To: binutils

# a.s
.globl weak1
.weak weak1
weak1:

.weak weak2
.globl weak2
weak2:

.local weak3
.weak weak3
weak3:

.weak weak4
.local weak4
weak4:

.weak (config/obj-elf.c) apparently overrides .globl (read.c) and .local
(config/obj-elf.c) but this seems accidental rather than intentional.

% as a.s -o a.o && readelf -Ws a.o

Symbol table '.symtab' contains 8 entries:
    Num:    Value          Size Type    Bind   Vis      Ndx Name
      0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
      1: 0000000000000000     0 SECTION LOCAL  DEFAULT    1
      2: 0000000000000000     0 SECTION LOCAL  DEFAULT    2
      3: 0000000000000000     0 SECTION LOCAL  DEFAULT    3
      4: 0000000000000000     0 NOTYPE  WEAK   DEFAULT    1 weak1
      5: 0000000000000000     0 NOTYPE  WEAK   DEFAULT    1 weak2
      6: 0000000000000000     0 NOTYPE  WEAK   DEFAULT    1 weak3
      7: 0000000000000000     0 NOTYPE  WEAK   DEFAULT    1 weak4

clang integrated assembler (LLVM MC) let the last directive win.

% llvm-mc -filetype=obj a.s -o a.o && readelf -Ws a.o

Symbol table '.symtab' contains 5 entries:
    Num:    Value          Size Type    Bind   Vis      Ndx Name
      0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
      1: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT    2 weak4
      2: 0000000000000000     0 NOTYPE  WEAK   DEFAULT    2 weak1
      3: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT    2 weak2
      4: 0000000000000000     0 NOTYPE  WEAK   DEFAULT    2 weak3


Should the assembler error for the second binding directive?

Should the assembler error for the second visibility directive? .protected / .hidden / .internal 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Error for the second binding (.local/.weak/.globl)
  2020-03-25  5:36 Error for the second binding (.local/.weak/.globl) Fangrui Song
@ 2020-03-25  8:41 ` Alan Modra
  2020-03-25 21:46   ` Fangrui Song
  0 siblings, 1 reply; 4+ messages in thread
From: Alan Modra @ 2020-03-25  8:41 UTC (permalink / raw)
  To: Fangrui Song; +Cc: binutils

On Tue, Mar 24, 2020 at 10:36:01PM -0700, Fangrui Song wrote:
> .weak (config/obj-elf.c) apparently overrides .globl (read.c) and .local
> (config/obj-elf.c) but this seems accidental rather than intentional.

No, it was deliberate.  git commit 5ca547dc239.

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Error for the second binding (.local/.weak/.globl)
  2020-03-25  8:41 ` Alan Modra
@ 2020-03-25 21:46   ` Fangrui Song
  2020-03-25 22:53     ` Alan Modra
  0 siblings, 1 reply; 4+ messages in thread
From: Fangrui Song @ 2020-03-25 21:46 UTC (permalink / raw)
  To: Alan Modra; +Cc: binutils

On 2020-03-25, Alan Modra wrote:
>On Tue, Mar 24, 2020 at 10:36:01PM -0700, Fangrui Song wrote:
>> .weak (config/obj-elf.c) apparently overrides .globl (read.c) and .local
>> (config/obj-elf.c) but this seems accidental rather than intentional.
>
>No, it was deliberate.  git commit 5ca547dc239.
>
>-- 
>Alan Modra
>Australia Development Lab, IBM

Ian does not remember what problems the commit fixed. He wouldn't have
done it on a whim. Maybe we can revisit the decision after 24 years.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Error for the second binding (.local/.weak/.globl)
  2020-03-25 21:46   ` Fangrui Song
@ 2020-03-25 22:53     ` Alan Modra
  0 siblings, 0 replies; 4+ messages in thread
From: Alan Modra @ 2020-03-25 22:53 UTC (permalink / raw)
  To: Fangrui Song; +Cc: binutils

On Wed, Mar 25, 2020 at 02:46:22PM -0700, Fangrui Song wrote:
> On 2020-03-25, Alan Modra wrote:
> > On Tue, Mar 24, 2020 at 10:36:01PM -0700, Fangrui Song wrote:
> > > .weak (config/obj-elf.c) apparently overrides .globl (read.c) and .local
> > > (config/obj-elf.c) but this seems accidental rather than intentional.
> > 
> > No, it was deliberate.  git commit 5ca547dc239.
> 
> Ian does not remember what problems the commit fixed. He wouldn't have
> done it on a whim.

gas emitted an error prior to that patch.  Quite likely it was due to
gcc at that time emitting both .global and .weak, or .local and .weak,
under some condition.

> Maybe we can revisit the decision after 24 years.

I think it is completely fine for you to make the llvm assembler error
on inconsistent binding, or the last directive win.  Either of those
behaviours is logical and good, but you quite possibly will run into a
need to fix more user assembly.

I also think it OK to leave gas as is, given that we have been that
way for many years without complaint, but I won't object if one of the
other global maintainers thinks we should change.

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-03-25 22:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-25  5:36 Error for the second binding (.local/.weak/.globl) Fangrui Song
2020-03-25  8:41 ` Alan Modra
2020-03-25 21:46   ` Fangrui Song
2020-03-25 22:53     ` Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).