public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Fangrui Song <i@maskray.me>
To: binutils@sourceware.org
Subject: Error for the second binding (.local/.weak/.globl)
Date: Tue, 24 Mar 2020 22:36:01 -0700	[thread overview]
Message-ID: <20200325053601.w6vxbh5ignc6bt65@gmail.com> (raw)

# 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 

             reply	other threads:[~2020-03-25  5:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-25  5:36 Fangrui Song [this message]
2020-03-25  8:41 ` Alan Modra
2020-03-25 21:46   ` Fangrui Song
2020-03-25 22:53     ` Alan Modra

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=20200325053601.w6vxbh5ignc6bt65@gmail.com \
    --to=i@maskray.me \
    --cc=binutils@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).