This is the mail archive of the
mailing list for the binutils project.
Re: [PATCH] Add type_unknown/type_executable/type_pic to output_type
- From: Alan Modra <amodra at gmail dot com>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: binutils at sourceware dot org
- Date: Sun, 23 Aug 2015 23:20:46 +0930
- 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>
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.
Next I tried reordering the enum a little, as well as the pad.
That gave me 11522515 bytes, which is even better than the result I
obtained with your patch..
Is any of this worth doing? Probably not. Fiddling around without
proper analysis isn't that useful. One thing I noticed is that both
of the following
#define bfd_link_executable(info) (bfd_link_pde (info) || bfd_link_pie (info))
#define bfd_link_pic(info) (bfd_link_dll (info) || bfd_link_pie (info))
ought to simplify to a single bit test, the first ought to test
bit0 == 0, and the second to test bit1 == 1. I spot checked a few
places and it appears that only bfd_link_executable(info) is ideal.
With my changes to enum output_type, both bfd_link_executable(info)
and bfd_link_pic(info) ought to still be a single bit test, but now
bfd_link_pic(info) generates ideal code but bfd_link_executable(info)
doesn't.. The gain I found is simply due to bfd_link_pic being more
$ findfile bfd ld | xargs grep bfd_link_executable | wc -l
$ findfile bfd ld | xargs grep bfd_link_pic | wc -l
I've opened https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67328
OK, so knowing that there is a gcc deficiency here, we could easily
work around that and write bfd_link_executable and bfd_link_pic as
directly testing the appropriate bit. I don't think that is a good
idea, as it is a little less obvious code, but the following may as
well be committed.
* bfdlink.h (enum output_type): Reorder enum.
diff --git a/include/bfdlink.h b/include/bfdlink.h
index 458a768..43bcc6a 100644
@@ -264,8 +264,8 @@ struct bfd_elf_version_tree;
Australia Development Lab, IBM