This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] Add type_unknown/type_executable/type_pic to output_type
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Alan Modra <amodra at gmail dot com>
- Cc: Binutils <binutils at sourceware dot org>
- Date: Sun, 23 Aug 2015 07:41:09 -0700
- Subject: Re: [PATCH] Add type_unknown/type_executable/type_pic to output_type
- Authentication-results: sourceware.org; auth=none
- References: <20150823020901 dot GA12630 at gmail dot com> <20150823135046 dot GC23693 at bubble dot grove dot modra dot org>
On Sun, Aug 23, 2015 at 6:50 AM, Alan Modra <amodra@gmail.com> wrote:
> Hmm, with x86_64 gcc 5.1.1 20150526, the size (as per size utility) of
> an --enable-targets=all ld went from 11546435 to 11537515 bytes with
> your patch. I wondered where this was coming from, so added
> unsigned int pad: 1;
> to struct bfd_link_info, after "type".
> That gave me 11546275 bytes. So some of the improvement from your
> patch is due to better location of other fields.
>
I compared the assembly outputs of elflink.c on x86-64 with GCC 5.2.1
using -O2 -g0:
[hjl@gnu-tools-1 bfd]$ wc -l old.s new.s
27370 old.s
27304 new.s
My patch removes 66 lines of assembly codes. I looked at
the differences and found:
old:
testb $8, 100(%rdi)
movq 16(%rsi), %rbp
jne .L631
movq 0(%rbp), %rax
xorl %r13d, %r13d
movzbl (%rax), %eax
movl %eax, %edx
andl $3, %edx
cmpb $1, %dl
jbe .L863
.L631:
cmpb $7, 24(%rbx)
je .L864
.L632:
movl 4(%r12), %r9d
testl %r9d, %r9d
jne .L865
testl %r13d, %r13d
jne .L739
.L635:
movq 8(%rbp), %rax
new
testb $8, 100(%rdi)
movq 16(%rsi), %rbp
jne .L628
movq 0(%rbp), %rax
xorl %r13d, %r13d
movzbl (%rax), %eax
testb $1, %al
jne .L862
.L628:
cmpb $7, 24(%rbx)
je .L863
.L629:
movl 4(%r12), %eax
testl %eax, %eax
jne .L864
testl %r13d, %r13d
jne .L733
.L632:
movq 8(%rbp), %rax
for
static bfd_boolean
elf_link_output_extsym (struct bfd_hash_entry *bh, void *data)
{
struct elf_link_hash_entry *h = (struct elf_link_hash_entry *) bh;
struct elf_outext_info *eoinfo = (struct elf_outext_info *) data;
struct elf_final_link_info *flinfo = eoinfo->flinfo;
bfd_boolean strip;
Elf_Internal_Sym sym;
asection *input_sec;
const struct elf_backend_data *bed;
long indx;
int ret;
/* A symbol is bound locally if it is forced local or it is locally
defined, hidden versioned, not referenced by shared library and
not exported when linking executable. */
bfd_boolean local_bind = (h->forced_local
|| (bfd_link_executable (flinfo->info)
&& !flinfo->info->export_dynamic
&& !h->dynamic
&& !h->ref_dynamic
&& h->def_regular
&& h->versioned == versioned_hidden));
My patch improves the generated code by changing
movzbl (%rax), %eax
movl %eax, %edx
andl $3, %edx
cmpb $1, %dl
to
movzbl (%rax), %eax
testb $1, %al
for bfd_link_executable (flinfo->info).
--
H.J.