From 4c6f24edd6b14450f90e51ccea70c9f9a848aba9 Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Fri, 4 Feb 2022 17:01:03 +0000 Subject: [PATCH] build: Fix notes Notes worked largely by chance. Give the note section a proper ELF type, and add a program header to capture the notes section too. Signed-off-by: Andrew Cooper --- arch/x86/link.lds.S | 18 +++++++++--------- include/xtf/asm_macros.h | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/arch/x86/link.lds.S b/arch/x86/link.lds.S index f7356dd..4daee1c 100644 --- a/arch/x86/link.lds.S +++ b/arch/x86/link.lds.S @@ -26,8 +26,8 @@ ENTRY(_elf_start) PHDRS { - /* Single loadable section, RWE. */ - load PT_LOAD FLAGS(7); + text PT_LOAD FLAGS(7); /* RWE */ + note PT_NOTE FLAGS(4); /* R */ } SECTIONS @@ -45,7 +45,7 @@ SECTIONS . = ALIGN(PAGE_SIZE); __end_user_text = .; - } :load = 0 + } :text = 0 .data : { *(.data) @@ -60,6 +60,11 @@ SECTIONS } + .note : { + *(.note) + *(.note.*) + } :note :text + .rodata : { *(.rodata) *(.rodata.*) @@ -68,12 +73,7 @@ SECTIONS __start_ex_table = .; *(.ex_table) __stop_ex_table = .; - } - - .note : { - *(.note) - *(.note.*) - } + } :text .bss : { *(.bss) diff --git a/include/xtf/asm_macros.h b/include/xtf/asm_macros.h index c531355..feb8ca3 100644 --- a/include/xtf/asm_macros.h +++ b/include/xtf/asm_macros.h @@ -62,7 +62,7 @@ name: * 'desc' may be an arbitrary asm construct. */ #define ELFNOTE(name, type, desc) \ - .pushsection .note.name ; \ + .pushsection .note.name, "a", @note ; \ .align 4 ; \ .long 2f - 1f /* namesz */ ; \ .long 4f - 3f /* descsz */ ; \ @@ -76,7 +76,7 @@ name: #else #define ELFNOTE(name, type, desc) \ - asm (".pushsection .note." #name ";" \ + asm (".pushsection .note, \"a\", @note;" \ ".align 4;" \ ".long 2f - 1f;" /* namesz */ \ ".long 4f - 3f;" /* descsz */ \ -- 2.39.5