aboutsummaryrefslogtreecommitdiff
path: root/src/types.h
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2009-06-10 21:56:01 -0400
committerKevin O'Connor <kevin@koconnor.net>2009-06-10 21:56:01 -0400
commitc0693941fdb5118164a8161316fdf8e9ebb499d2 (patch)
tree4c2ed73a666bed4a8742453262c5899f77f7bfde /src/types.h
parent0b04b78972939b8bf00c6b075b3592ea6b7dd643 (diff)
downloadseabios-hppa-c0693941fdb5118164a8161316fdf8e9ebb499d2.zip
seabios-hppa-c0693941fdb5118164a8161316fdf8e9ebb499d2.tar.gz
seabios-hppa-c0693941fdb5118164a8161316fdf8e9ebb499d2.tar.bz2
Do garbage collection of unused sections.
Implement -ffunction-sections and -fdata-sections in both 32bit and 16bit code. Make sure all sections have unique names (even asm and discarded sections). Enhance tools/layoutrom.py script to find all sections reachable from exported 16bit code - prune all other sections. Mark sections with "export" if they can be visible outside of code - these sections wont be dropped when pruning unused sections.
Diffstat (limited to 'src/types.h')
-rw-r--r--src/types.h22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/types.h b/src/types.h
index 52e508b..a004474 100644
--- a/src/types.h
+++ b/src/types.h
@@ -23,26 +23,35 @@ union u64_u32_u {
#define __VISIBLE __attribute__((externally_visible))
+#define UNIQSEC __FILE__ "." __stringify(__LINE__)
+
+#define __ASM(code) asm(".section .text.asm." UNIQSEC "\n\t" code)
+
#if MODE16 == 1
// Notes a function as externally visible in the 16bit code chunk.
# define VISIBLE16 __VISIBLE
// Notes a function as externally visible in the 32bit code chunk.
# define VISIBLE32
// Designate a variable as (only) visible to 16bit code.
-# define VAR16 __attribute__((section(".data16." __FILE__ "." __stringify(__LINE__))))
+# define VAR16 __section(".data16." UNIQSEC)
// Designate a variable as visible to both 32bit and 16bit code.
# define VAR16_32 VAR16 __VISIBLE
+// Designate a variable visible externally.
+# define VAR16EXPORT __section(".data16.export." UNIQSEC) __VISIBLE
// Designate a variable at a specific 16bit address
-# define VAR16FIXED(addr) __aligned(1) __VISIBLE __attribute__((section(".fixedaddr." __stringify(addr))))
+# define VAR16FIXED(addr) __aligned(1) __VISIBLE __section(".fixedaddr." __stringify(addr))
// Designate top-level assembler as 16bit only.
-# define ASM16(code) asm(".section .text.asm." __FILE__ "." __stringify(__LINE__) "\n\t" code)
+# define ASM16(code) __ASM(code)
+# define ASM32(code)
#else
# define VISIBLE16
# define VISIBLE32 __VISIBLE
-# define VAR16 __attribute__((section(".discard.var16")))
-# define VAR16_32 VAR16 __VISIBLE __attribute__((weak))
+# define VAR16 __section(".discard.var16." UNIQSEC)
+# define VAR16_32 VAR16 __VISIBLE __weak
+# define VAR16EXPORT VAR16_32
# define VAR16FIXED(addr) VAR16_32
# define ASM16(code)
+# define ASM32(code) __ASM(code)
#endif
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
@@ -54,6 +63,9 @@ union u64_u32_u {
#define NULL ((void *)0)
+#define __weak __attribute__((weak))
+#define __section(S) __attribute__((section(S)))
+
#define PACKED __attribute__((packed))
#define __aligned(x) __attribute__((aligned(x)))