dynamic linker: permit error returns from arch-specific reloc function

the immediate motivation is supporting TLSDESC relocations which
require allocation and thus may fail (unless we pre-allocate), but
this mechanism should also be used for throwing an error on
unsupported or invalid relocation types, and perhaps in certain cases,
for reporting when a relocation is not satisfiable.
This commit is contained in:
Rich Felker 2014-06-16 03:09:07 -04:00
commit bfa09700b9
8 changed files with 16 additions and 8 deletions

View file

@ -19,7 +19,7 @@
#define IS_COPY(x) ((x)==R_ARM_COPY) #define IS_COPY(x) ((x)==R_ARM_COPY)
#define IS_PLT(x) ((x)==R_ARM_JUMP_SLOT) #define IS_PLT(x) ((x)==R_ARM_JUMP_SLOT)
static inline void do_single_reloc( static inline int do_single_reloc(
struct dso *self, unsigned char *base_addr, struct dso *self, unsigned char *base_addr,
size_t *reloc_addr, int type, size_t addend, size_t *reloc_addr, int type, size_t addend,
Sym *sym, size_t sym_size, Sym *sym, size_t sym_size,
@ -51,6 +51,7 @@ static inline void do_single_reloc(
: self->tls_offset + 8; : self->tls_offset + 8;
break; break;
} }
return 0;
} }
#define NO_LEGACY_INITFINI #define NO_LEGACY_INITFINI

View file

@ -6,7 +6,7 @@
#define IS_COPY(x) ((x)==R_386_COPY) #define IS_COPY(x) ((x)==R_386_COPY)
#define IS_PLT(x) ((x)==R_386_JMP_SLOT) #define IS_PLT(x) ((x)==R_386_JMP_SLOT)
static inline void do_single_reloc( static inline int do_single_reloc(
struct dso *self, unsigned char *base_addr, struct dso *self, unsigned char *base_addr,
size_t *reloc_addr, int type, size_t addend, size_t *reloc_addr, int type, size_t addend,
Sym *sym, size_t sym_size, Sym *sym, size_t sym_size,
@ -46,4 +46,5 @@ static inline void do_single_reloc(
: self->tls_offset; : self->tls_offset;
break; break;
} }
return 0;
} }

View file

@ -13,7 +13,7 @@
#define IS_COPY(x) ((x)==R_MICROBLAZE_COPY) #define IS_COPY(x) ((x)==R_MICROBLAZE_COPY)
#define IS_PLT(x) ((x)==R_MICROBLAZE_JUMP_SLOT) #define IS_PLT(x) ((x)==R_MICROBLAZE_JUMP_SLOT)
static inline void do_single_reloc( static inline int do_single_reloc(
struct dso *self, unsigned char *base_addr, struct dso *self, unsigned char *base_addr,
size_t *reloc_addr, int type, size_t addend, size_t *reloc_addr, int type, size_t addend,
Sym *sym, size_t sym_size, Sym *sym, size_t sym_size,
@ -38,6 +38,7 @@ static inline void do_single_reloc(
*reloc_addr = def.sym->st_value + addend; *reloc_addr = def.sym->st_value + addend;
break; break;
} }
return 0;
} }
#include "syscall.h" #include "syscall.h"

View file

@ -19,7 +19,7 @@
#define IS_COPY(x) ((x)==R_MIPS_COPY) #define IS_COPY(x) ((x)==R_MIPS_COPY)
#define IS_PLT(x) 1 #define IS_PLT(x) 1
static inline void do_single_reloc( static inline int do_single_reloc(
struct dso *self, unsigned char *base_addr, struct dso *self, unsigned char *base_addr,
size_t *reloc_addr, int type, size_t addend, size_t *reloc_addr, int type, size_t addend,
Sym *sym, size_t sym_size, Sym *sym, size_t sym_size,
@ -48,6 +48,7 @@ static inline void do_single_reloc(
: self->tls_offset - 0x7000; : self->tls_offset - 0x7000;
break; break;
} }
return 0;
} }
void __reloc_self(int c, size_t *a, size_t *dynv, size_t *got) void __reloc_self(int c, size_t *a, size_t *dynv, size_t *got)

View file

@ -7,7 +7,7 @@
#define IS_PLT(x) ((x)==R_PPC_JMP_SLOT) #define IS_PLT(x) ((x)==R_PPC_JMP_SLOT)
// see linux' arch/powerpc/include/asm/elf.h // see linux' arch/powerpc/include/asm/elf.h
static inline void do_single_reloc( static inline int do_single_reloc(
struct dso *self, unsigned char *base_addr, struct dso *self, unsigned char *base_addr,
size_t *reloc_addr, int type, size_t addend, size_t *reloc_addr, int type, size_t addend,
Sym *sym, size_t sym_size, Sym *sym, size_t sym_size,
@ -37,6 +37,7 @@ static inline void do_single_reloc(
: self->tls_offset - 0x7000; : self->tls_offset - 0x7000;
break; break;
} }
return 0;
} }
void __reloc_self(int c, size_t *a, size_t *dynv) void __reloc_self(int c, size_t *a, size_t *dynv)

View file

@ -9,7 +9,7 @@
#define IS_COPY(x) ((x) == R_SH_COPY) #define IS_COPY(x) ((x) == R_SH_COPY)
#define IS_PLT(x) ((x) == R_SH_JMP_SLOT) #define IS_PLT(x) ((x) == R_SH_JMP_SLOT)
static inline void do_single_reloc( static inline int do_single_reloc(
struct dso *self, unsigned char *base_addr, struct dso *self, unsigned char *base_addr,
size_t *reloc_addr, int type, size_t addend, size_t *reloc_addr, int type, size_t addend,
Sym *sym, size_t sym_size, Sym *sym, size_t sym_size,
@ -44,4 +44,5 @@ static inline void do_single_reloc(
: self->tls_offset + 8; : self->tls_offset + 8;
break; break;
} }
return 0;
} }

View file

@ -7,7 +7,7 @@
#define IS_COPY(x) ((x)==R_X86_64_COPY) #define IS_COPY(x) ((x)==R_X86_64_COPY)
#define IS_PLT(x) ((x)==R_X86_64_JUMP_SLOT) #define IS_PLT(x) ((x)==R_X86_64_JUMP_SLOT)
static inline void do_single_reloc( static inline int do_single_reloc(
struct dso *self, unsigned char *base_addr, struct dso *self, unsigned char *base_addr,
size_t *reloc_addr, int type, size_t addend, size_t *reloc_addr, int type, size_t addend,
Sym *sym, size_t sym_size, Sym *sym, size_t sym_size,
@ -43,4 +43,5 @@ static inline void do_single_reloc(
: 0 - self->tls_offset) + addend; : 0 - self->tls_offset) + addend;
break; break;
} }
return 0;
} }

View file

@ -7,7 +7,7 @@
#define IS_COPY(x) ((x)==R_X86_64_COPY) #define IS_COPY(x) ((x)==R_X86_64_COPY)
#define IS_PLT(x) ((x)==R_X86_64_JUMP_SLOT) #define IS_PLT(x) ((x)==R_X86_64_JUMP_SLOT)
static inline void do_single_reloc( static inline int do_single_reloc(
struct dso *self, unsigned char *base_addr, struct dso *self, unsigned char *base_addr,
size_t *reloc_addr, int type, size_t addend, size_t *reloc_addr, int type, size_t addend,
Sym *sym, size_t sym_size, Sym *sym, size_t sym_size,
@ -43,4 +43,5 @@ static inline void do_single_reloc(
: 0 - self->tls_offset) + addend; : 0 - self->tls_offset) + addend;
break; break;
} }
return 0;
} }