Make .rodata a recognized ELF section with default attributes

This commit is contained in:
H. Peter Anvin 2002-05-17 04:51:10 +00:00
parent 64af0aa6de
commit 77a036e213
3 changed files with 12 additions and 4 deletions

View 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.)

View 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);

View 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]