From 511b1d37c2722d863cd56500df846f6048402620 Mon Sep 17 00:00:00 2001 From: kettenis Date: Sat, 27 Dec 2014 13:13:25 +0000 Subject: [PATCH] Make ld.so process only R_ALPHA_RELATIVE relocations during early GOT relocation in _reloc_alpha_got(), and teach RELOC_RELA() to skip R_ALPHA_NONE relocations (which are just nops used to fill out the relocation table). Handling R_ALPHA_NONE relocations will be necessary for static PIE support and it is not inconceivable that ld.so will end up with such relocations at some point. ok kurt@ --- libexec/ld.so/alpha/archdep.h | 4 +++- libexec/ld.so/alpha/rtld_machine.c | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/libexec/ld.so/alpha/archdep.h b/libexec/ld.so/alpha/archdep.h index 44e7f595bf7..930efed3929 100644 --- a/libexec/ld.so/alpha/archdep.h +++ b/libexec/ld.so/alpha/archdep.h @@ -1,4 +1,4 @@ -/* $OpenBSD: archdep.h,v 1.15 2014/11/03 17:50:56 guenther Exp $ */ +/* $OpenBSD: archdep.h,v 1.16 2014/12/27 13:13:25 kettenis Exp $ */ /* * Copyright (c) 1998 Per Fogelstrom, Opsycon AB @@ -54,6 +54,8 @@ RELOC_RELA(Elf64_Rela *r, const Elf64_Sym *s, Elf64_Addr *p, unsigned long v, { if (ELF64_R_TYPE(r->r_info) == RELOC_RELATIVE) { /* handled by _reloc_alpha_got */ + } else if (ELF64_R_TYPE(r->r_info) == RELOC_NONE) { + /* nothing to do */ } else if (ELF64_R_TYPE(r->r_info) == RELOC_JMP_SLOT) { Elf64_Addr val = v + s->st_value + r->r_addend - (Elf64_Addr)(p); diff --git a/libexec/ld.so/alpha/rtld_machine.c b/libexec/ld.so/alpha/rtld_machine.c index 221c9c014e1..ce41b65fd1c 100644 --- a/libexec/ld.so/alpha/rtld_machine.c +++ b/libexec/ld.so/alpha/rtld_machine.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtld_machine.c,v 1.51 2014/04/16 10:52:58 guenther Exp $ */ +/* $OpenBSD: rtld_machine.c,v 1.52 2014/12/27 13:13:25 kettenis Exp $ */ /* * Copyright (c) 1999 Dale Rahn @@ -375,8 +375,9 @@ _reloc_alpha_got(Elf_Dyn *dynp, Elf_Addr relocbase) } relalim = (const Elf_RelA *)((caddr_t)rela + relasz); for (; rela < relalim; rela++) { + if (ELF64_R_TYPE(rela->r_info) != RELOC_RELATIVE) + continue; where = (Elf_Addr *)(relocbase + rela->r_offset); - /* XXX For some reason I see a few GLOB_DAT relocs here. */ *where += (Elf_Addr)relocbase; } } -- 2.20.1