Make .rodata a recognized ELF section with default attributes
authorH. Peter Anvin <hpa@zytor.com>
Fri, 17 May 2002 04:51:10 +0000 (04:51 +0000)
committerH. Peter Anvin <hpa@zytor.com>
Fri, 17 May 2002 04:51:10 +0000 (04:51 +0000)
doc/nasmdoc.src
output/outelf.c
test/elftest.asm

index 280ebe2..33a2f20 100644 (file)
@@ -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.)
index 4518217..152e1d2 100644 (file)
@@ -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);
index c5a729f..fcfb362 100644 (file)
@@ -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]