Reputation: 615
In my x86-64 kernel, I am trying to map the .rodata
ELF section as readonly. But all the string literals, are stored in a file-specific section, e.g. .rodata.str1.8
. Are there any option for GCC to store all strings in .rodata
instead, or can I concatenate the .rodata.str.x
into .rodata
using ld
, objdump
or anything else?
ENTRY(_start)
SECTIONS {
. = 0xC0100000;
kernel_memory_start = .;
.boot ALIGN(8) :
{
*(.multiboot)
}
.text ALIGN(4K) : AT(ADDR(.text) - 0xC0000000)
{
kernel_text_start = .;
*(.text)
}
kernel_text_end = .;
.rodata ALIGN(4K) : AT(ADDR(.rodata) - 0xC0000000)
{
kernel_rodata_start = .;
*(.rodata)
}
kernel_rodata_end = .;
.data ALIGN(4K) : AT(ADDR(.data) - 0xC0000000)
{
kernel_data_start = .;
*(.data)
}
kernel_data_end = .;
.bss ALIGN(4K) : AT(ADDR(.bss) - 0xC0000000)
{
kernel_bss_start = .;
*(.bss)
}
kernel_bss_end = .;
kernel_memory_end = .;
}
Compiler flags:
gcc -ffreestanding -mcmodel=large -fno-pic -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -mno-3dnow -mno-80387 -fno-unwind-tables ...
Linker flags:
ld -nostdlib -n ...
Upvotes: 1
Views: 1669