From 90b1ccff86d530b140eb391ede3c50e33bcf9410 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Thu, 12 Sep 2019 20:21:03 -0400 Subject: Drop unnecessary EXTERN symbols Currently, NASM always issues as an unknown symbol any symbol declared EXTERN. This is highly undesirable when using common header files, as it might cause the linker to pull in a bunch of unnecessary modules, depending on how smart the linker is. Add a new REQUIRED directive which behaves like the old EXTERN, for the use cases which might still need this behavior. Signed-off-by: H. Peter Anvin (Intel) --- include/labels.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/labels.h b/include/labels.h index 9cf57c1b..32df8071 100644 --- a/include/labels.h +++ b/include/labels.h @@ -48,17 +48,22 @@ enum mangle_index { }; enum label_type { - LBL_LOCAL, /* Must be zero */ - LBL_GLOBAL, + LBL_NONE = -1, /* No label */ + LBL_LOCAL = 0, /* Must be zero */ LBL_STATIC, + LBL_GLOBAL, LBL_EXTERN, + LBL_REQUIRED, /* Like extern but emit even if unused */ LBL_COMMON, LBL_SPECIAL, /* Magic symbols like ..start */ LBL_BACKEND /* Backend-defined symbols like ..got */ }; -bool lookup_label(const char *label, int32_t *segment, int64_t *offset); -bool is_extern(const char *label); +enum label_type lookup_label(const char *label, int32_t *segment, int64_t *offset); +static inline bool is_extern(enum label_type type) +{ + return type == LBL_EXTERN || type == LBL_REQUIRED; +} void define_label(const char *label, int32_t segment, int64_t offset, bool normal); void backend_label(const char *label, int32_t segment, int64_t offset); -- cgit v1.2.1