소스 검색

generalize mips-specific reloc code not to hard-code sym/type encoding

this change is made in preparation for adding the mips64 port, which
needs a 64-bit (and mips64-specific) form of the R_INFO macro, but
it's a better abstraction anyway.

based on part of the mips64 port patch by Mahesh Bodapati and Jaydeep
Patil of Imagination Technologies.
Rich Felker 9 년 전
부모
커밋
71392a91c3
2개의 변경된 파일3개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      ldso/dynlink.c
  2. 2 0
      src/internal/dynlink.h

+ 1 - 1
ldso/dynlink.c

@@ -1134,7 +1134,7 @@ static void do_mips_relocs(struct dso *p, size_t *got)
 	Sym *sym = p->syms + j;
 	rel[0] = (unsigned char *)got - base;
 	for (i-=j; i; i--, sym++, rel[0]+=sizeof(size_t)) {
-		rel[1] = sym-p->syms << 8 | R_MIPS_JUMP_SLOT;
+		rel[1] = R_INFO(sym-p->syms, R_MIPS_JUMP_SLOT);
 		do_relocs(p, rel, sizeof rel, 2);
 	}
 }

+ 2 - 0
src/internal/dynlink.h

@@ -11,12 +11,14 @@ typedef Elf32_Phdr Phdr;
 typedef Elf32_Sym Sym;
 #define R_TYPE(x) ((x)&255)
 #define R_SYM(x) ((x)>>8)
+#define R_INFO ELF32_R_INFO
 #else
 typedef Elf64_Ehdr Ehdr;
 typedef Elf64_Phdr Phdr;
 typedef Elf64_Sym Sym;
 #define R_TYPE(x) ((x)&0x7fffffff)
 #define R_SYM(x) ((x)>>32)
+#define R_INFO ELF64_R_INFO
 #endif
 
 /* These enum constants provide unmatchable default values for