From d159ef5c6604160db3fb3694920f480c0fa4a462 Mon Sep 17 00:00:00 2001 From: Pawel Wieczorkiewicz Date: Mon, 26 Oct 2020 15:07:06 +0100 Subject: [PATCH] asm: add STRING() and STRING_LEN() macros The macros declare string in assembly and allow to get its size. Example: STRING(str, This is string) STRING_LEN(str) While touching the file, apply small cleanup. Signed-off-by: Pawel Wieczorkiewicz --- include/arch/x86/asm-macros.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/include/arch/x86/asm-macros.h b/include/arch/x86/asm-macros.h index 1cc0f6fe..8817f81b 100644 --- a/include/arch/x86/asm-macros.h +++ b/include/arch/x86/asm-macros.h @@ -127,14 +127,21 @@ #define SIZE(name) \ .size name, (. - name); -#define END_OBJECT(name) \ - .type name, STT_OBJECT; \ +#define END_OBJECT(name) \ + .type name, STT_OBJECT; \ SIZE(name) -#define END_FUNC(name) \ - .type name, STT_FUNC; \ +#define END_FUNC(name) \ + .type name, STT_FUNC; \ SIZE(name) +#define STRING(name, text) \ +name:; \ + .asciz #text; \ +name ## _end: + +#define STRING_LEN(name) (name ## _end - name) + #define ELF_NOTE(name, type, size, addr) \ .section .note.name, "a"; \ .align 4; \