@@ -146,9 +146,22 @@ SECTIONS
#endif
} :text =0xcccc
- /* End of text section, which should occupy whole number of pages */
- _etext = .;
+ /*
+ * -ffunction-sections creates .text.* sections, which are considered
+ * "orphan sections" and added after the first similar section (.text).
+ * Placing this ALIGN statement before _etext causes the address of
+ * _etext to be below that of all the .text.* orphaned sections
+ */
. = ALIGN(PAGE_SIZE);
+ _etext = .;
+
+ /*
+ * the size of the .text section is used to calculate the address
+ * range for orc lookups. If we just use SIZEOF(.text), we will
+ * miss all the .text.* sections. Calculate the size using _etext
+ * and _stext and save the value for later.
+ */
+ text_size = _etext - _stext;
X86_ALIGN_RODATA_BEGIN
RO_DATA(PAGE_SIZE)
@@ -835,7 +835,7 @@
. = ALIGN(4); \
.orc_lookup : AT(ADDR(.orc_lookup) - LOAD_OFFSET) { \
orc_lookup = .; \
- . += (((SIZEOF(.text) + LOOKUP_BLOCK_SIZE - 1) / \
+ . += (((text_size + LOOKUP_BLOCK_SIZE - 1) / \
LOOKUP_BLOCK_SIZE) + 1) * 4; \
orc_lookup_end = .; \
}