summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2019-09-12 20:21:03 -0400
committerH. Peter Anvin <hpa@zytor.com>2019-09-12 20:21:03 -0400
commit90b1ccff86d530b140eb391ede3c50e33bcf9410 (patch)
tree1ef248693a5d5b8c226a99f2626734f4f76f88c5 /include
parent495fda63418600229f36a3a7de62b75620be34b6 (diff)
downloadnasm-90b1ccff86d530b140eb391ede3c50e33bcf9410.tar.gz
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) <hpa@zytor.com>
Diffstat (limited to 'include')
-rw-r--r--include/labels.h13
1 files changed, 9 insertions, 4 deletions
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);