blob: f67939977a47b799b6e553d9948f56caabf32975 [file] [log] [blame]
#ifndef _LINUX_SECTIONS_H
#define _LINUX_SECTIONS_H
#define SECTION_RODATA .rodata
#define SECTION_TEXT .text
#define SECTION_DATA .data
#define SECTION_INIT .init.text
#define SECTION_INIT_DATA .init.data
#define SECTION_INIT_RODATA .init.rodata
#define SECTION_INIT_CALL .initcall
#define SECTION_EXIT .exit.text
#define SECTION_EXIT_DATA .exit.data
#define SECTION_EXIT_CALL .exitcall.exit
#define SECTION_REF .ref.text
#define SECTION_REF_DATA .ref.data
#define SECTION_REF_RODATA .ref.rodata
#define SECTION_SCHED .sched.text
#ifdef __ASSEMBLY__
#define SECTION_TYPE(section, type, name, level) \
.pushsection section ## . ## type ## . ## name ## . ## level
#else
#define LINUX_SECTION_ALIGNMENT(name) __alignof__(__typeof__(name[0]))
/*
* Force functions to an 8 byte alignement to make sure they are aligned
* to the same function alignment expected on most architectures.
*
* Without this, at least on i386, it has been observed that on second pass
* ld may align some symbols to a 4 byte boundary, whereas nm output shifts
* some of these symbols out of place inconsistently. The second ld pass is
* done when generating System.map.
*
* Refer to commit 6d30e3a8995c9 ("kbuild: Avoid inconsistent kallsyms data"),
* for more details.
*/
#define LINUX_SECTION_ALIGN_FUNC 8
/*
* When adding custom data structures to the linker script a "start" and "end"
* address is typically assigned, respectively LINUX_SECTION_START() and
* LINUX_SECTION_END(). Without an explicit alignment stated there may
* be a mismatch between where the linker assigns LINUX_SECTION_START() and
* where we end up getting new data actually stored. In the worst case
* crashes have been observed after gcc started to use bigger alignment for
* structs (32 bytes), refer to commit 07fca0e57fca9 (tracing: Properly align
* linker defined symbols") for more details. To avoid any possible issues
* you can use this structural alignemnt to void mismatches and be explicit
* to match gcc's alignement for structs.
*/
#define LINUX_SECTION_ALIGN_STRUCT 32
#define LINUX_SECTION_SIZE(name) ((name##__end) - (name))
#define LINUX_SECTION_EMPTY(name) (LINUX_RANGE_SIZE(name) == 0)
#define LINUX_SECTION_START(name) name
#define LINUX_SECTION_END(name) name##__end
#define LINUX_SECTION(name, section) \
#section "." #name
#define DECLARE_LINUX_SECTION(type, name) \
extern type name[], name##__end[];
#define DECLARE_LINUX_SECTION_RO(type, name) \
extern const type name[], name##__end[];
#define __SECTION_TYPE(section, type, name, level) \
#section "." #type "." #name "." #level
#define SECTION_TYPE(section, type, name, level) \
__SECTION_TYPE(section, type, name, level)
#define SECTION_ORDER_ANY any
#endif /* __ASSEMBLY__ */
/*
* This section is for use on linker scripts and helpers
*/
#define SECTION_TYPE_ALL(section, type) \
section##.##type.*
#endif /* _LINUX_SECTIONS_H */