public inbox for gnu-gabi@sourceware.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: Alan Modra <amodra@gmail.com>
Cc: Michael Matz <matz@suse.de>, gnu-gabi@sourceware.org
Subject: Re: Specify how undefined weak symbol should be resolved in executable
Date: Fri, 01 Jan 2016 00:00:00 -0000	[thread overview]
Message-ID: <CAMe9rOp1QHCyhV--Es9kSSBEqJs4ZGRGTqPeJ4mEYJsrymUmeQ@mail.gmail.com> (raw)
In-Reply-To: <20160223044029.GE10657@bubble.grove.modra.org>

On Mon, Feb 22, 2016 at 8:40 PM, Alan Modra <amodra@gmail.com> wrote:
>
> However, that might be a bad idea.  Lots of C++ code uses weak symbols
> for functions defined in header files, and other objects with vague
> linkage.  These result in weak definitions in eg. libstdc++.so.  I'm
> not sure how many executables take the address of such functions and
> thus might become DT_TEXTREL.

Most, if not all, of programs will have DT_TEXTREL on x86 if undefined
weak symbols require dynamic relocations.


-- 
H.J.
---
[hjl@gnu-4 ~]$ objdump -dwr  /usr/lib/gcc/x86_64-redhat-linux/5.3.1/crtbegin.o
/usr/lib/gcc/x86_64-redhat-linux/5.3.1/crtbegin.o:     file format elf64-x86-64


Disassembly of section .text:

0000000000000000 <deregister_tm_clones>:
   0: b8 00 00 00 00       mov    $0x0,%eax 1: R_X86_64_32 __TMC_END__+0x7
   5: 55                   push   %rbp
   6: 48 2d 00 00 00 00     sub    $0x0,%rax 8: R_X86_64_32S .tm_clone_table
   c: 48 83 f8 0e           cmp    $0xe,%rax
  10: 48 89 e5             mov    %rsp,%rbp
  13: 76 1b                 jbe    30 <deregister_tm_clones+0x30>
  15: b8 00 00 00 00       mov    $0x0,%eax 16: R_X86_64_32
_ITM_deregisterTMCloneTable
  1a: 48 85 c0             test   %rax,%rax
  1d: 74 11                 je     30 <deregister_tm_clones+0x30>
  1f: 5d                   pop    %rbp
  20: bf 00 00 00 00       mov    $0x0,%edi 21: R_X86_64_32 .tm_clone_table
  25: ff e0                 jmpq   *%rax
  27: 66 0f 1f 84 00 00 00 00 00 nopw   0x0(%rax,%rax,1)
  30: 5d                   pop    %rbp
  31: c3                   retq
  32: 0f 1f 40 00           nopl   0x0(%rax)
  36: 66 2e 0f 1f 84 00 00 00 00 00 nopw   %cs:0x0(%rax,%rax,1)

0000000000000040 <register_tm_clones>:
  40: be 00 00 00 00       mov    $0x0,%esi 41: R_X86_64_32 __TMC_END__
  45: 55                   push   %rbp
  46: 48 81 ee 00 00 00 00 sub    $0x0,%rsi 49: R_X86_64_32S .tm_clone_table
  4d: 48 c1 fe 03           sar    $0x3,%rsi
  51: 48 89 e5             mov    %rsp,%rbp
  54: 48 89 f0             mov    %rsi,%rax
  57: 48 c1 e8 3f           shr    $0x3f,%rax
  5b: 48 01 c6             add    %rax,%rsi
  5e: 48 d1 fe             sar    %rsi
  61: 74 15                 je     78 <register_tm_clones+0x38>
  63: b8 00 00 00 00       mov    $0x0,%eax 64: R_X86_64_32
_ITM_registerTMCloneTable
  68: 48 85 c0             test   %rax,%rax
  6b: 74 0b                 je     78 <register_tm_clones+0x38>
  6d: 5d                   pop    %rbp
  6e: bf 00 00 00 00       mov    $0x0,%edi 6f: R_X86_64_32 .tm_clone_table
  73: ff e0                 jmpq   *%rax
  75: 0f 1f 00             nopl   (%rax)
  78: 5d                   pop    %rbp
  79: c3                   retq
  7a: 66 0f 1f 44 00 00     nopw   0x0(%rax,%rax,1)

0000000000000080 <__do_global_dtors_aux>:
  80: 80 3d 00 00 00 00 00 cmpb   $0x0,0x0(%rip)        # 87
<__do_global_dtors_aux+0x7> 82: R_X86_64_PC32 .bss-0x5
  87: 75 11                 jne    9a <__do_global_dtors_aux+0x1a>
  89: 55                   push   %rbp
  8a: 48 89 e5             mov    %rsp,%rbp
  8d: e8 6e ff ff ff       callq  0 <deregister_tm_clones>
  92: 5d                   pop    %rbp
  93: c6 05 00 00 00 00 01 movb   $0x1,0x0(%rip)        # 9a
<__do_global_dtors_aux+0x1a> 95: R_X86_64_PC32 .bss-0x5
  9a: f3 c3                 repz retq
  9c: 0f 1f 40 00           nopl   0x0(%rax)

00000000000000a0 <frame_dummy>:
  a0: bf 00 00 00 00       mov    $0x0,%edi a1: R_X86_64_32 .jcr
  a5: 48 83 3f 00           cmpq   $0x0,(%rdi)
  a9: 75 05                 jne    b0 <frame_dummy+0x10>
  ab: eb 93                 jmp    40 <register_tm_clones>
  ad: 0f 1f 00             nopl   (%rax)
  b0: b8 00 00 00 00       mov    $0x0,%eax b1: R_X86_64_32 _Jv_RegisterClasses
  b5: 48 85 c0             test   %rax,%rax
  b8: 74 f1                 je     ab <frame_dummy+0xb>
  ba: 55                   push   %rbp
  bb: 48 89 e5             mov    %rsp,%rbp
  be: ff d0                 callq  *%rax
  c0: 5d                   pop    %rbp
  c1: e9 7a ff ff ff       jmpq   40 <register_tm_clones>
[hjl@gnu-4 ~]$ readelf -sW
/usr/lib/gcc/x86_64-redhat-linux/5.3.1/crtbegin.o  | grep WEAK
    23: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND
_ITM_deregisterTMCloneTable
    24: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND
_ITM_registerTMCloneTable
    26: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND _Jv_RegisterClasses
[hjl@gnu-4 ~]$

  reply	other threads:[~2016-02-23 13:01 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-01  0:00 H.J. Lu
2016-01-01  0:00 ` H.J. Lu
2016-01-01  0:00   ` H.J. Lu
2016-01-01  0:00   ` Michael Matz
2016-01-01  0:00     ` H.J. Lu
2016-01-01  0:00       ` Michael Matz
2016-01-01  0:00         ` H.J. Lu
2016-01-01  0:00           ` H.J. Lu
2016-01-01  0:00             ` Alan Modra
2016-01-01  0:00               ` H.J. Lu [this message]
2016-01-01  0:00                 ` Michael Matz
2016-01-01  0:00                   ` H.J. Lu
2016-01-01  0:00                     ` Michael Matz
2016-01-01  0:00                       ` Szabolcs Nagy
2016-01-01  0:00                         ` Michael Matz
2016-01-01  0:00               ` H.J. Lu
2016-01-01  0:00                 ` Michael Matz
2016-01-01  0:00                   ` H.J. Lu
2016-01-01  0:00                     ` Michael Matz
2016-01-01  0:00                       ` H.J. Lu
2016-01-01  0:00                         ` Alan Modra
2016-01-01  0:00                           ` H.J. Lu
2016-01-01  0:00                             ` Alan Modra
2016-01-01  0:00                               ` Carlos O'Donell
2016-01-01  0:00                                 ` H.J. Lu
2016-01-01  0:00                                   ` Michael Matz
2016-01-01  0:00                                     ` H.J. Lu
2016-01-01  0:00                                       ` Michael Matz
2016-01-01  0:00                                         ` H.J. Lu
2016-01-01  0:00                                           ` Michael Matz
2016-01-01  0:00                                             ` H.J. Lu
2016-01-01  0:00                         ` H.J. Lu
2016-01-01  0:00             ` H.J. Lu
2016-01-01  0:00               ` H.J. Lu

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=CAMe9rOp1QHCyhV--Es9kSSBEqJs4ZGRGTqPeJ4mEYJsrymUmeQ@mail.gmail.com \
    --to=hjl.tools@gmail.com \
    --cc=amodra@gmail.com \
    --cc=gnu-gabi@sourceware.org \
    --cc=matz@suse.de \
    /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).