Jelajahi Sumber

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.
Rich Felker 10 tahun lalu
induk
melakukan
bfa09700b9

+ 2 - 1
arch/arm/reloc.h

@@ -19,7 +19,7 @@
 #define IS_COPY(x) ((x)==R_ARM_COPY)
 #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,
 	size_t *reloc_addr, int type, size_t addend,
 	Sym *sym, size_t sym_size,
@@ -51,6 +51,7 @@ static inline void do_single_reloc(
 			: self->tls_offset + 8;
 		break;
 	}
+	return 0;
 }
 
 #define NO_LEGACY_INITFINI

+ 2 - 1
arch/i386/reloc.h

@@ -6,7 +6,7 @@
 #define IS_COPY(x) ((x)==R_386_COPY)
 #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,
 	size_t *reloc_addr, int type, size_t addend,
 	Sym *sym, size_t sym_size,
@@ -46,4 +46,5 @@ static inline void do_single_reloc(
 			: self->tls_offset;
 		break;
 	}
+	return 0;
 }

+ 2 - 1
arch/microblaze/reloc.h

@@ -13,7 +13,7 @@
 #define IS_COPY(x) ((x)==R_MICROBLAZE_COPY)
 #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,
 	size_t *reloc_addr, int type, size_t addend,
 	Sym *sym, size_t sym_size,
@@ -38,6 +38,7 @@ static inline void do_single_reloc(
 		*reloc_addr = def.sym->st_value + addend;
 		break;
 	}
+	return 0;
 }
 
 #include "syscall.h"

+ 2 - 1
arch/mips/reloc.h

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

+ 2 - 1
arch/powerpc/reloc.h

@@ -7,7 +7,7 @@
 #define IS_PLT(x) ((x)==R_PPC_JMP_SLOT)
 
 // 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,
 	size_t *reloc_addr, int type, size_t addend,
 	Sym *sym, size_t sym_size,
@@ -37,6 +37,7 @@ static inline void do_single_reloc(
 			: self->tls_offset - 0x7000;
 		break;
 	}
+	return 0;
 }
 
 void __reloc_self(int c, size_t *a, size_t *dynv)

+ 2 - 1
arch/sh/reloc.h

@@ -9,7 +9,7 @@
 #define IS_COPY(x) ((x) == R_SH_COPY)
 #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,
 	size_t *reloc_addr, int type, size_t addend,
 	Sym *sym, size_t sym_size,
@@ -44,4 +44,5 @@ static inline void do_single_reloc(
 			: self->tls_offset + 8;
 		break;
 	}
+	return 0;
 }

+ 2 - 1
arch/x32/reloc.h

@@ -7,7 +7,7 @@
 #define IS_COPY(x) ((x)==R_X86_64_COPY)
 #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,
 	size_t *reloc_addr, int type, size_t addend,
 	Sym *sym, size_t sym_size,
@@ -43,4 +43,5 @@ static inline void do_single_reloc(
 			: 0 - self->tls_offset) + addend;
 		break;
 	}
+	return 0;
 }

+ 2 - 1
arch/x86_64/reloc.h

@@ -7,7 +7,7 @@
 #define IS_COPY(x) ((x)==R_X86_64_COPY)
 #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,
 	size_t *reloc_addr, int type, size_t addend,
 	Sym *sym, size_t sym_size,
@@ -43,4 +43,5 @@ static inline void do_single_reloc(
 			: 0 - self->tls_offset) + addend;
 		break;
 	}
+	return 0;
 }