diff options
author | Dale Rahn <drahn@cvs.openbsd.org> | 2003-09-04 19:37:09 +0000 |
---|---|---|
committer | Dale Rahn <drahn@cvs.openbsd.org> | 2003-09-04 19:37:09 +0000 |
commit | 728366afbd8a31bc70424bf0b64579cdfef0a2a1 (patch) | |
tree | 70ef6cf6f9085f1c8fcb25356e371013e4d87d1e /libexec/ld.so/powerpc/rtld_machine.c | |
parent | 29153d4f5d5ce3630a02cc3cf4cf730b0a5ead11 (diff) |
Fix W^X mistake. If the dynamic linker is workin in non-lazy mode, it
should still mprotect the GOT and PLT as appropriate. ok deraadt@ miod@
Diffstat (limited to 'libexec/ld.so/powerpc/rtld_machine.c')
-rw-r--r-- | libexec/ld.so/powerpc/rtld_machine.c | 52 |
1 files changed, 27 insertions, 25 deletions
diff --git a/libexec/ld.so/powerpc/rtld_machine.c b/libexec/ld.so/powerpc/rtld_machine.c index 3500e888f53..c8aee7ba5db 100644 --- a/libexec/ld.so/powerpc/rtld_machine.c +++ b/libexec/ld.so/powerpc/rtld_machine.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtld_machine.c,v 1.31 2003/09/04 19:33:49 drahn Exp $ */ +/* $OpenBSD: rtld_machine.c,v 1.32 2003/09/04 19:37:07 drahn Exp $ */ /* * Copyright (c) 1999 Dale Rahn @@ -511,31 +511,33 @@ _dl_md_reloc_got(elf_object_t *object, int lazy) if (!lazy) { _dl_md_reloc(object, DT_JMPREL, DT_PLTRELSZ); - return; - } - first_rela = (Elf32_Addr *) - (((Elf32_Rela *)(object->Dyn.info[DT_JMPREL]))->r_offset + - object->load_offs); - pltresolve = (Elf32_Addr *)(first_rela) - 18; - - relas = (Elf32_Rela *)(object->Dyn.info[DT_JMPREL]); - numrela = object->Dyn.info[DT_PLTRELSZ] / sizeof(Elf32_Rela); - r_addr = (Elf32_Addr *)(relas->r_offset + object->load_offs); - - for (i = 0, index = 0; i < numrela; i++, r_addr+=2, index++) { - if (index >= (2 << 12)) { - /* addis r11,r11,.PLTtable@ha*/ - r_addr[0] = ADDIS_R11_R0 | HA(index*4); - r_addr[1] = ADDI_R11_R11 | L(index*4); - BR(r_addr[2], pltresolve); - /* only every other slot is used after index == 2^14 */ - r_addr += 2; - } else { - r_addr[0] = LI_R11 | (index * 4); - BR(r_addr[1], pltresolve); + } else { + first_rela = (Elf32_Addr *) + (((Elf32_Rela *)(object->Dyn.info[DT_JMPREL]))->r_offset + + object->load_offs); + pltresolve = (Elf32_Addr *)(first_rela) - 18; + + relas = (Elf32_Rela *)(object->Dyn.info[DT_JMPREL]); + numrela = object->Dyn.info[DT_PLTRELSZ] / sizeof(Elf32_Rela); + r_addr = (Elf32_Addr *)(relas->r_offset + object->load_offs); + + for (i = 0, index = 0; i < numrela; i++, r_addr+=2, index++) { + if (index >= (2 << 12)) { + /* addis r11,r0,.PLTtable@ha*/ + r_addr[0] = ADDIS_R11_R0 | HA(index*4); + r_addr[1] = ADDI_R11_R11 | L(index*4); + BR(r_addr[2], pltresolve); + /* only every other slot is used after + * index == 2^14 + */ + r_addr += 2; + } else { + r_addr[0] = LI_R11 | (index * 4); + BR(r_addr[1], pltresolve); + } + _dl_dcbf(&r_addr[0]); + _dl_dcbf(&r_addr[2]); } - _dl_dcbf(&r_addr[0]); - _dl_dcbf(&r_addr[2]); } if (object->got_size != 0) { |