[klibc] [PATCH] ELF headers

Thayne Harbaugh tharbaugh at lnxi.com
Thu Jan 6 14:26:34 PST 2005


This is a patch that I've had kicking around that I never sent in.  With
it applied I can compile the module programs from module-init-tools:

diff -uNr klibc-0.178/include/sys/elf32.h klibc-0.178-fogo/include/sys/elf32.h
--- klibc-0.178/include/sys/elf32.h	2004-01-30 14:40:51.000000000 -0700
+++ klibc-0.178-fogo/include/sys/elf32.h	2004-09-20 09:15:58.000000000 -0600
@@ -7,6 +7,10 @@
 
 #include <sys/elfcommon.h>
 
+#define ELF32_ST_BIND(val)		ST_BIND (val)
+#define ELF32_ST_TYPE(val)		ST_TYPE (val)
+#define ELF32_ST_INFO(bind, type)	ST_INFO ((bind), (type))
+
 /* ELF standard typedefs (yet more proof that <stdint.h> was way overdue) */
 typedef uint16_t  Elf32_Half;
 typedef int16_t   Elf32_SHalf;
diff -uNr klibc-0.178/include/sys/elf64.h klibc-0.178-fogo/include/sys/elf64.h
--- klibc-0.178/include/sys/elf64.h	2004-01-30 14:40:51.000000000 -0700
+++ klibc-0.178-fogo/include/sys/elf64.h	2004-09-20 09:15:50.000000000 -0600
@@ -7,6 +7,10 @@
 
 #include <sys/elfcommon.h>
 
+#define ELF64_ST_BIND(val)		ST_BIND (val)
+#define ELF64_ST_TYPE(val)		ST_TYPE (val)
+#define ELF64_ST_INFO(bind, type)	ST_INFO ((bind), (type))
+
 /* ELF standard typedefs (yet more proof that <stdint.h> was way overdue) */
 typedef uint16_t  Elf64_Half;
 typedef int16_t   Elf64_SHalf;
diff -uNr klibc-0.178/include/sys/elfcommon.h klibc-0.178-fogo/include/sys/elfcommon.h
--- klibc-0.178/include/sys/elfcommon.h	2004-01-30 14:40:51.000000000 -0700
+++ klibc-0.178-fogo/include/sys/elfcommon.h	2004-09-20 09:21:09.000000000 -0600
@@ -2,6 +2,8 @@
  * sys/elfcommon.h
  */
 
+#include <stdint.h>
+
 #ifndef _SYS_ELFCOMMON_H
 #define _SYS_ELFCOMMON_H
 
@@ -182,5 +184,33 @@
 #define ELFOSABI_NONE   0
 #define ELFOSABI_LINUX  3
 
+/* How to extract and insert information held in the st_info field.  */
+
+#define ST_BIND(val)		(((unsigned char) (val)) >> 4)
+#define ST_TYPE(val)		((val) & 0xf)
+#define ST_INFO(bind, type)	(((bind) << 4) + ((type) & 0xf))
+
+#define STB_LOCAL	0	/* local symbol */
+#define STB_GLOBAL	1	/* global symbol */
+#define STB_WEAK	2	/* weak symbol */
+#define	STB_NUM		3	/* number of defined types.  */
+#define STB_LOOS	10	/* start of OS-specific */
+#define STB_HIOS	12	/* end of OS-specific */
+#define STB_LOPROC	13	/* start of processor-specific */
+#define STB_HIPROC	15	/* end of processor-specific */
+
+#define STT_NOTYPE	0	/* symbol type is unspecified */
+#define STT_OBJECT	1	/* symbol is a data object */
+#define STT_FUNC	2	/* symbol is a code object */
+#define STT_SECTION	3	/* symbol associated with a section */
+#define STT_FILE	4	/* symbol's name is file name */
+#define STT_COMMON	5	/* symbol is a common data object */
+#define STT_TLS		6	/* symbol is thread-local data object*/
+#define	STT_NUM		7	/* number of defined types.  */
+#define STT_LOOS	10	/* start of OS-specific */
+#define STT_HIOS	12	/* end of OS-specific */
+#define STT_LOPROC	13	/* start of processor-specific */
+#define STT_HIPROC	15	/* end of processor-specific */
+
 #endif /* _SYS_ELFCOMMON_H */
 

-- 
Thayne Harbaugh
Linux Networx



More information about the klibc mailing list