tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Macro to define absolute symbol



I want to define absolute symbols in ELF files, using as(1) '.equiv' directive,
as done in _KERNEL_OPT_* symbols in kernel build.  Could anyone look and
complete this, including the !__STDC__ part and cdefs_aout.h?

My use-case is to define COHERENCY_UNIT for linker script.

Index: sys/sys/cdefs_elf.h
===================================================================
RCS file: /cvsroot/src/sys/sys/cdefs_elf.h,v
retrieving revision 1.46
diff -p -u -r1.46 cdefs_elf.h
--- sys/sys/cdefs_elf.h	26 Aug 2014 09:03:17 -0000	1.46
+++ sys/sys/cdefs_elf.h	7 Nov 2014 04:06:50 -0000
@@ -130,6 +130,16 @@
 	      ".popsection")
 #endif
 
+#if __STDC__
+#define	__SYMVAL(sym, val)						\
+	__asm(".globl	" #sym);					\
+	__asm(".equiv	" #sym ", " __STRING(val))
+#else
+#define	__SYMVAL(sym, val)						\
+	__asm(".globl	sym");						\
+	__asm(".equiv	sym, " __STRING(val))
+#endif
+
 #define	__IDSTRING(_n,_s)		__SECTIONSTRING(.ident,_s)
 
 #define	__RCSID(_s)			__IDSTRING(rcsid,_s)


Home | Main Index | Thread Index | Old Index