[PATCH] Add type_unknown/type_executable/type_pic to output_type
Alan Modra
amodra@gmail.com
Sun Aug 23 13:50:00 GMT 2015
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))
with
enum output_type
{
type_pde,
type_relocatable,
type_pie,
type_dll,
};
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
common.
$ findfile bfd ld | xargs grep bfd_link_executable | wc -l
177
$ findfile bfd ld | xargs grep bfd_link_pic | wc -l
1028
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
--- a/include/bfdlink.h
+++ b/include/bfdlink.h
@@ -264,8 +264,8 @@ struct bfd_elf_version_tree;
enum output_type
{
type_pde,
- type_relocatable,
type_pie,
+ type_relocatable,
type_dll,
};
--
Alan Modra
Australia Development Lab, IBM
More information about the Binutils
mailing list