This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
remove the PF_W of the text program section
- From: "Noah yan" <noah dot yan at gmail dot com>
- To: binutils at sourceware dot org
- Date: Tue, 8 Aug 2006 17:12:29 -0700
- Subject: remove the PF_W of the text program section
Hi all,
I use a linker scripts to create a bootup binary, but the text program
section is always set as PF_W, PF_R PF_X and my loader need it to be
set as RX only. How can I do this? thanks in advance.
ld -dy -o unix -e _start -I misc/krtld -T Mapfile
Here is my ld.script and elfdump of the headers
OUTPUT_ARCH(powerpc:common)
SECTIONS
{
/* Read-only sections, merged into text segment: */
. = 0x800000 ;
_text = .;
.text :
{
*(.text)
}
_etext = .;
PROVIDE (etext = .);
.interp : { *(.interp)>>-------}
.hash : { *(.hash)>-->-------}
.dynsym : { *(.dynsym)>>-------}
.dynstr : { *(.dynstr)>>-------}
.rel.text : { *(.rel.text)>------}
.rela.text : { *(.rela.text) >----}
.rel.data : { *(.rel.data)>------}
.rela.data : { *(.rela.data) >----}
.rel.rodata : { *(.rel.rodata) >---}
.rela.rodata : { *(.rela.rodata) >--}
.rodata : { *(.rodata)>>-------}
.rodata1 : { *(.rodata1)>-------}
.rel.got : { *(.rel.got)>-------}
.rela.got : { *(.rela.got)>------}
.rel.ctors : { *(.rel.ctors)>-----}
.rela.ctors : { *(.rela.ctors)>----}
.rel.dtors : { *(.rel.dtors)>-----}
.rela.dtors : { *(.rela.dtors)>----}
.rel.bss : { *(.rel.bss)>-------}
.rela.bss : { *(.rela.bss)>------}
.rel.plt : { *(.rel.plt)>-------}
.rela.plt : { *(.rela.plt)>------}
.plt : { *(.plt) }
/* Read-write section, merged into data segment: */
. = ALIGN(4096);
_data = .;
.data :
{
*(.data)
*(.data1)
*(.sdata)
*(.sdata2)
*(.got.plt) *(.got)
*(.got1)
}
_edata = .;
PROVIDE (edata = .);
. = ALIGN(4096);
__bss_start = .;
.bss :
{
*(.sbss) *(.scommon)
*(.dynbss)
*(.bss)
*(COMMON)
}
_end = . ;
PROVIDE (end = .);
}
ELF Header
ei_magic: { 0x7f, E, L, F }
ei_class: ELFCLASS32 ei_data: ELFDATA2MSB
e_machine: EM_PPC e_version: EV_CURRENT
e_type: ET_EXEC
e_flags: 0
e_entry: 0x800000 e_ehsize: 52 e_shstrndx: 24
e_shoff: 0x29edbc e_shentsize: 40 e_shnum: 27
e_phoff: 0x34 e_phentsize: 32 e_phnum: 5
Program Header[0]:
p_vaddr: 0x10034 p_flags: [ PF_X PF_R ]
p_paddr: 0 p_type: [ PT_PHDR ]
p_filesz: 0xa0 p_memsz: 0xa0
p_offset: 0x34 p_align: 0x4
Program Header[1]:
p_vaddr: 0x872f00 p_flags: [ PF_R ]
p_paddr: 0x872f00 p_type: [ PT_INTERP ]
p_filesz: 0xb p_memsz: 0xb
p_offset: 0x82f00 p_align: 0x1
Program Header[2]:
p_vaddr: 0x800000 p_flags: [ PF_X PF_W PF_R ]
p_paddr: 0x800000 p_type: [ PT_LOAD ]
p_filesz: 0x8a90c p_memsz: 0x8b524
p_offset: 0x10000 p_align: 0x10000
Program Header[3]:
p_vaddr: 0x88c000 p_flags: [ PF_X PF_W PF_R ]
p_paddr: 0x88c000 p_type: [ PT_LOAD ]
p_filesz: 0x7f8c p_memsz: 0x31299
p_offset: 0x9c000 p_align: 0x10000
Program Header[4]:
p_vaddr: 0x893ee4 p_flags: [ PF_W PF_R ]
p_paddr: 0x893ee4 p_type: [ PT_DYNAMIC ]
p_filesz: 0xa8 p_memsz: 0xa8
p_offset: 0xa3ee4 p_align: 0x4