From c577060f8cd652164ac246c2cb93f04b18cba29e Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Fri, 22 Apr 2016 20:00:30 +0100 Subject: [PATCH] Introduce DECLSTR() for declaring strings in ASM Put the string in the mergeable string section, declare it as data, and set its size. Replace the partial open-coding of this in head_{pv,hvm}.S for main_err_msg, and switch the label to being local. Signed-off-by: Andrew Cooper --- arch/x86/boot/head_hvm.S | 9 +++------ arch/x86/boot/head_pv.S | 9 +++------ include/xtf/asm_macros.h | 13 +++++++++++++ 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/arch/x86/boot/head_hvm.S b/arch/x86/boot/head_hvm.S index 7f503d6..3288216 100644 --- a/arch/x86/boot/head_hvm.S +++ b/arch/x86/boot/head_hvm.S @@ -74,17 +74,14 @@ GLOBAL(_start) /* HVM common setup. */ /* panic() if xtf_main manages to return. */ #ifdef __x86_64__ - lea main_err_msg(%rip), %rdi + lea .Lmain_err_msg(%rip), %rdi #else - push $main_err_msg + push $.Lmain_err_msg #endif call panic ENDFUNC(_start) -.section .rodata.str1, "aMS", @progbits, 1 - -main_err_msg: .asciz "xtf_main() returned\n" -SIZE(main_err_msg) +DECLSTR(.Lmain_err_msg, "xtf_main() returned\n") /* * Local variables: diff --git a/arch/x86/boot/head_pv.S b/arch/x86/boot/head_pv.S index cdb1b2b..88fa8cf 100644 --- a/arch/x86/boot/head_pv.S +++ b/arch/x86/boot/head_pv.S @@ -41,17 +41,14 @@ GLOBAL(_start) /* panic() if xtf_main manages to return. */ #ifdef __x86_64__ - lea main_err_msg(%rip), %rdi + lea .Lmain_err_msg(%rip), %rdi #else - push $main_err_msg + push $.Lmain_err_msg #endif call panic ENDFUNC(_start) -.section .rodata.str1, "aMS", @progbits, 1 - -main_err_msg: .asciz "xtf_main() returned\n" -SIZE(main_err_msg) +DECLSTR(.Lmain_err_msg, "xtf_main() returned\n") /* * Local variables: diff --git a/include/xtf/asm_macros.h b/include/xtf/asm_macros.h index 1806fa1..1fe00ff 100644 --- a/include/xtf/asm_macros.h +++ b/include/xtf/asm_macros.h @@ -43,6 +43,19 @@ name: .type name, STT_FUNC; \ SIZE(name) +/** + * Declare a string with label @p name and value @p val. It is placed in the + * mergable string section, is declared as data, and has its size set. + * @param name String name. + * @param val String content. + */ +#define DECLSTR(name, val) \ + .pushsection .rodata.str1, "aMS", @progbits, 1; \ + name: .asciz val; \ + .type name, STT_OBJECT; \ + SIZE(name) \ + .popsection + /** * Create an ELF note entry. * -- 2.39.5