From 77a036e2135258a8cee158dbe24908ab045aac3d Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Fri, 17 May 2002 04:51:10 +0000 Subject: [PATCH] Make .rodata a recognized ELF section with default attributes --- doc/nasmdoc.src | 9 +++++---- output/outelf.c | 3 +++ test/elftest.asm | 4 ++++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/doc/nasmdoc.src b/doc/nasmdoc.src index 280ebe2..33a2f20 100644 --- a/doc/nasmdoc.src +++ b/doc/nasmdoc.src @@ -4024,10 +4024,11 @@ requirements of the section. The defaults assumed by NASM if you do not specify the above qualifiers are: -\c section .text progbits alloc exec nowrite align=16 -\c section .data progbits alloc noexec write align=4 -\c section .bss nobits alloc noexec write align=4 -\c section other progbits alloc noexec nowrite align=1 +\c section .text progbits alloc exec nowrite align=16 +\c section .rodata progbits alloc noexec nowrite align=4 +\c section .data progbits alloc noexec write align=4 +\c section .bss nobits alloc noexec write align=4 +\c section other progbits alloc noexec nowrite align=1 (Any section name other than \c{.text}, \c{.data} and \c{.bss} is treated by default like \c{other} in the above code.) diff --git a/output/outelf.c b/output/outelf.c index 4518217..152e1d2 100644 --- a/output/outelf.c +++ b/output/outelf.c @@ -327,6 +327,9 @@ static long elf_section_names (char *name, int pass, int *bits) if (!strcmp(name, ".text")) i = elf_make_section (name, SHT_PROGBITS, SHF_ALLOC | SHF_EXECINSTR, 16); + else if (!strcmp(name, ".rodata")) + i = elf_make_section (name, SHT_PROGBITS, + SHF_ALLOC, 4); else if (!strcmp(name, ".data")) i = elf_make_section (name, SHT_PROGBITS, SHF_ALLOC | SHF_WRITE, 4); diff --git a/test/elftest.asm b/test/elftest.asm index c5a729f..fcfb362 100644 --- a/test/elftest.asm +++ b/test/elftest.asm @@ -22,6 +22,7 @@ ; [15] Reference a text-section symbol in the data section ; [16] Reference a data-section symbol in the data section ; [17] Reference a BSS-section symbol in the data section +; [18] Define a non-global rodata-section symbol BITS 32 GLOBAL lrotate ; [1] @@ -81,3 +82,6 @@ integer resd 1 ; [3] ; a local integer localint resd 1 ; [6] + + SECTION .rodata +readonly dd readonly ; [18] -- 2.7.4