Add macro to mark a symbol as weak. Use it to mark the end of a linker

set as empty linker set otherwise violate the aliasing rules of C by
presenting zero sized objects.
This commit is contained in:
joerg 2014-12-08 20:50:11 +00:00
parent 785f046bf0
commit 447f8618b7
1 changed files with 8 additions and 2 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: cdefs_elf.h,v 1.46 2014/08/26 09:03:17 christos Exp $ */
/* $NetBSD: cdefs_elf.h,v 1.47 2014/12/08 20:50:11 joerg Exp $ */
/*
* Copyright (c) 1995, 1996 Carnegie-Mellon University.
@ -64,6 +64,12 @@
#define __weak_extern(sym) \
__asm(".weak " _C_LABEL_STRING(#sym));
#if __GNUC_PREREQ__(4, 0)
#define __weak __attribute__((__weak__))
#else
#define __weak
#endif
#if __GNUC_PREREQ__(4, 0)
#define __weak_reference(sym) __attribute__((__weakref__(#sym)))
#else
@ -169,7 +175,7 @@
#define __link_set_decl(set, ptype) \
extern ptype * const __link_set_start(set)[] __dso_hidden; \
extern ptype * const __link_set_end(set)[] __dso_hidden
extern ptype * const __link_set_end(set)[] __weak __dso_hidden
#define __link_set_count(set) \
(__link_set_end(set) - __link_set_start(set))