Proper attributes for .init entries

This commit is contained in:
Mark
2020-07-28 14:55:55 +03:00
parent 49431c2cdf
commit 0beace2dcd
+8 -1
View File
@@ -6,7 +6,14 @@
#pragma once
#define __weak __attribute__((weak))
// A bit of assembler "sorcery" here:
// By default (with only section name specified) gcc will spit out:
// .section .init,"aw",@progbits
// But .init section is "ax", so the result will be
// .section .init,"ax",@progbits //"aw",@progbits
// '//' will just comment out the stuff GCC produced
#define __init(name) \
static void name(void); \
const void *__init_##name __attribute__((section(".init"),used)) = name; \
const void *__init_##name __attribute__((section(".init,\"ax\",@progbits //"),used)) = name; \
static void name(void)