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

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).