From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 115193 invoked by alias); 23 Feb 2016 13:01:01 -0000 Mailing-List: contact gnu-gabi-help@sourceware.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Subscribe: Sender: gnu-gabi-owner@sourceware.org Received: (qmail 115168 invoked by uid 89); 23 Feb 2016 13:01:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.99 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=amodragmailcom, amodra@gmail.com, 0xe, 0x3f X-Spam-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on sourceware.org X-Spam-Level: X-HELO: mail-qg0-f51.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=+aQU4fuKlO8N/D9e/JhbSfq7B8FDEhCLwQo4Jy+Pslk=; b=UYeBPWMNxAQ66O1h0WVKm845RiZfU+9JtHIYiKMIZWm0B6KD6ih+TGeCKTOb/byA/z RnNK8ZAUiv0JCsxtacJ4Z83oRZEXKJzYdFx9cku8ckM/3nlDrVfgJXh5wHTfWa6AyhfW weDzLPqTH5xjR4CiE/EsusAErPBSa+oRdM9Q6Hy0VPT4mhffJCqxhsYqptaEp+PuSeiU LMd1GvqnwmftX2XMk7YmtBiEJ5moK6tmERDvmKz8/Vvp36fQ7uiz4/SuCwdn76tvMQfj 7tfMvQkiwfHH97mKk1+qP3rFQeCeTiKhGU043cp28UHbkBXdNYywik2HgoFQEd1ZiDQ3 iNcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=+aQU4fuKlO8N/D9e/JhbSfq7B8FDEhCLwQo4Jy+Pslk=; b=UhP3wDm8N8O877s+pjNpESfiykw1lcRLTVo838ewmmxn3PFd+gIaVTI9QMIiaxXUzp 7ANnYcXg/0t57BqStLEk9hHd0L/nXUEUUnESMNGAKqro8bRRlvGV0ylm8JzHlrejE1Xv 95uJWSyRGFq+ocLRrtnHQEJWEkDNJBJVKSvMGYZI0Ch15COWDZbcGDzzB/nqOmTVmh2i pUAAfx8EW0ZWlwrUWoc3HEtdb2n4cNDPHYV68Pyfye0lTa2YLCgs/c1OL+DzLIJVr1yu TIR7TumOs+3LHrCBZQunP6N2KXbFbn9FByVgMxjZhaFg4SE2iusKUDd7NMT0Ad2C/Hl9 kGRA== X-Gm-Message-State: AG10YOSnX7QTJInTFNQVm2FWsfLhmOYZ+g+KP5owMwG4nvzlezcG3tNtskAqnxzyfAKfo44JubgZ29tfnz8oKA== MIME-Version: 1.0 X-Received: by 10.140.19.52 with SMTP id 49mr41200294qgg.103.1456232454220; Tue, 23 Feb 2016 05:00:54 -0800 (PST) In-Reply-To: <20160223044029.GE10657@bubble.grove.modra.org> References: <20160223044029.GE10657@bubble.grove.modra.org> Date: Fri, 01 Jan 2016 00:00:00 -0000 Message-ID: Subject: Re: Specify how undefined weak symbol should be resolved in executable From: "H.J. Lu" To: Alan Modra Cc: Michael Matz , gnu-gabi@sourceware.org Content-Type: text/plain; charset=UTF-8 X-SW-Source: 2016-q1/txt/msg00015.txt.bz2 On Mon, Feb 22, 2016 at 8:40 PM, Alan Modra 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 : 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 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 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 : 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 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 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 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 : 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 ab: eb 93 jmp 40 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 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 [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 ~]$