This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] Add type_unknown/type_executable/type_pic to output_type
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: binutils at sourceware dot org
- Date: Sat, 22 Aug 2015 19:09:01 -0700
- Subject: [PATCH] Add type_unknown/type_executable/type_pic to output_type
- Authentication-results: sourceware.org; auth=none
This patch adds to enum output_type so that bfd_link_executable and
bfd_link_pic can be simplifed a little bit. On Linux/x86-64, it
reduces the linker code size by 168 bytes.
Any comments, feedbacks?
H.J.
---
include/
* bfdlink.h (output_type): Add type_unknown, type_executable
and type_pic.
(bfd_link_executable): Updated.
(bfd_link_pic): Likewise.
(bfd_link_info): Change type to 3 bits.
ld/
* lexsup.c (parse_args): Default output type to type_pde.
---
include/bfdlink.h | 17 ++++++++++-------
ld/lexsup.c | 4 ++++
2 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/include/bfdlink.h b/include/bfdlink.h
index 458a768..1d0ca35 100644
--- a/include/bfdlink.h
+++ b/include/bfdlink.h
@@ -263,18 +263,21 @@ struct bfd_elf_version_tree;
enum output_type
{
- type_pde,
- type_relocatable,
- type_pie,
- type_dll,
+ type_unknown = 0,
+ type_executable = 1 << 0,
+ type_relocatable = 1 << 1,
+ type_pic = 1 << 2,
+ type_dll = type_pic,
+ type_pde = type_executable,
+ type_pie = (type_executable | type_pic)
};
#define bfd_link_pde(info) ((info)->type == type_pde)
#define bfd_link_dll(info) ((info)->type == type_dll)
#define bfd_link_relocatable(info) ((info)->type == type_relocatable)
#define bfd_link_pie(info) ((info)->type == type_pie)
-#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))
+#define bfd_link_executable(info) (((info)->type & type_executable) != 0)
+#define bfd_link_pic(info) (((info)->type & type_pic) != 0)
/* This structure holds all the information needed to communicate
between BFD and the linker when doing a link. */
@@ -282,7 +285,7 @@ enum output_type
struct bfd_link_info
{
/* Output type. */
- ENUM_BITFIELD (output_type) type : 2;
+ ENUM_BITFIELD (output_type) type : 3;
/* TRUE if BFD should pre-bind symbols in a shared object. */
unsigned int symbolic: 1;
diff --git a/ld/lexsup.c b/ld/lexsup.c
index ace1803..2700929 100644
--- a/ld/lexsup.c
+++ b/ld/lexsup.c
@@ -1518,6 +1518,10 @@ parse_args (unsigned argc, char **argv)
}
}
+ /* Default output type to PDE. */
+ if (link_info.type == type_unknown)
+ link_info.type = type_pde;
+
if (command_line.soname && command_line.soname[0] == '\0')
{
einfo (_("%P: SONAME must not be empty string; ignored\n"));
--
2.4.3