public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* remove the PF_W of the text program section
@ 2006-08-09  0:26 Noah yan
  2006-08-09  0:44 ` Alan Modra
  0 siblings, 1 reply; 7+ messages in thread
From: Noah yan @ 2006-08-09  0:26 UTC (permalink / raw)
  To: binutils

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2006-08-10  3:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-09  0:26 remove the PF_W of the text program section Noah yan
2006-08-09  0:44 ` Alan Modra
2006-08-09  0:58   ` Noah yan
2006-08-09  1:24     ` Alan Modra
2006-08-09 18:04       ` Noah yan
2006-08-10  3:53         ` Alan Modra
2006-08-10 14:08           ` Noah yan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).