Index: kern/link_elf.c =================================================================== RCS file: /home/ncvs/src/sys/kern/link_elf.c,v retrieving revision 1.60 diff -u -r1.60 link_elf.c --- kern/link_elf.c 17 Sep 2002 01:48:58 -0000 1.60 +++ kern/link_elf.c 27 Sep 2002 15:08:07 -0000 @@ -1188,6 +1188,16 @@ } #endif +const Elf_Sym * +elf_get_sym(linker_file_t lf, Elf_Word symidx) +{ + elf_file_t ef = (elf_file_t)lf; + + if (symidx >= ef->nchains) + return (NULL); + return (ef->symtab + symidx); +} + /* * Symbol lookup function that can be used when the symbol index is known (ie * in relocations). It uses the symbol index instead of doing a fully fledged Index: sparc64/sparc64/elf_machdep.c =================================================================== RCS file: /home/ncvs/src/sys/sparc64/sparc64/elf_machdep.c,v retrieving revision 1.9 diff -u -r1.9 elf_machdep.c --- sparc64/sparc64/elf_machdep.c 1 Sep 2002 21:41:24 -0000 1.9 +++ sparc64/sparc64/elf_machdep.c 27 Sep 2002 14:09:46 -0000 @@ -131,10 +131,10 @@ _RF_S|_RF_A|_RF_P| _RF_SZ(32) | _RF_RS(0), /* DISP_32 */ _RF_S|_RF_A|_RF_P| _RF_SZ(32) | _RF_RS(2), /* WDISP_30 */ _RF_S|_RF_A|_RF_P| _RF_SZ(32) | _RF_RS(2), /* WDISP_22 */ - _RF_A| _RF_B|_RF_SZ(32) | _RF_RS(10), /* HI22 */ + _RF_S|_RF_A| _RF_SZ(32) | _RF_RS(10), /* HI22 */ _RF_S|_RF_A| _RF_SZ(32) | _RF_RS(0), /* 22 */ _RF_S|_RF_A| _RF_SZ(32) | _RF_RS(0), /* 13 */ - _RF_A| _RF_B|_RF_SZ(32) | _RF_RS(0), /* LO10 */ + _RF_S|_RF_A| _RF_SZ(32) | _RF_RS(0), /* LO10 */ _RF_G| _RF_SZ(32) | _RF_RS(0), /* GOT10 */ _RF_G| _RF_SZ(32) | _RF_RS(0), /* GOT13 */ _RF_G| _RF_SZ(32) | _RF_RS(10), /* GOT22 */ @@ -144,8 +144,8 @@ _RF_SZ(32) | _RF_RS(0), /* COPY */ _RF_S|_RF_A| _RF_SZ(64) | _RF_RS(0), /* GLOB_DAT */ _RF_SZ(32) | _RF_RS(0), /* JMP_SLOT */ - _RF_A| _RF_B|_RF_SZ(64) | _RF_RS(0), /* RELATIVE */ - _RF_S|_RF_A| _RF_U|_RF_SZ(32) | _RF_RS(0), /* UA_32 */ + _RF_A| _RF_B| _RF_SZ(64) | _RF_RS(0), /* RELATIVE */ + _RF_S|_RF_A| _RF_U| _RF_SZ(32) | _RF_RS(0), /* UA_32 */ _RF_A| _RF_SZ(32) | _RF_RS(0), /* PLT32 */ _RF_A| _RF_SZ(32) | _RF_RS(10), /* HIPLT22 */ @@ -181,6 +181,22 @@ _RF_S|_RF_A| _RF_U| _RF_SZ(16) | _RF_RS(0), /* UA16 */ }; +#if 0 +static const char *reloc_names[] = { + "NONE", "RELOC_8", "RELOC_16", "RELOC_32", "DISP_8", + "DISP_16", "DISP_32", "WDISP_30", "WDISP_22", "HI22", + "22", "13", "LO10", "GOT10", "GOT13", + "GOT22", "PC10", "PC22", "WPLT30", "COPY", + "GLOB_DAT", "JMP_SLOT", "RELATIVE", "UA_32", "PLT32", + "HIPLT22", "LOPLT10", "LOPLT10", "PCPLT22", "PCPLT32", + "10", "11", "64", "OLO10", "HH22", + "HM10", "LM22", "PC_HH22", "PC_HM10", "PC_LM22", + "WDISP16", "WDISP19", "GLOB_JMP", "7", "5", "6", + "DISP64", "PLT64", "HIX22", "LOX10", "H44", "M44", + "L44", "REGISTER", "UA64", "UA16" +}; +#endif + #define RELOC_RESOLVE_SYMBOL(t) ((reloc_target_flags[t] & _RF_S) != 0) #define RELOC_PC_RELATIVE(t) ((reloc_target_flags[t] & _RF_P) != 0) #define RELOC_BASE_RELATIVE(t) ((reloc_target_flags[t] & _RF_B) != 0) @@ -224,6 +240,7 @@ elf_reloc(linker_file_t lf, const void *data, int type) { const Elf_Rela *rela; + const Elf_Sym *sym; Elf_Addr relocbase; Elf_Half *where32; Elf_Addr *where; @@ -255,10 +272,15 @@ value = rela->r_addend; if (RELOC_RESOLVE_SYMBOL(rtype)) { - addr = elf_lookup(lf, symidx, 1); - if (addr == 0) - return (-1); - value += addr; + sym = elf_get_sym(lf, symidx); + if (ELF_ST_BIND(sym->st_info) == STB_LOCAL) + value += relocbase; + else { + addr = elf_lookup(lf, symidx, 1); + if (addr == 0) + return (-1); + value += addr; + } } if (RELOC_PC_RELATIVE(rtype)) Index: sys/linker.h =================================================================== RCS file: /home/ncvs/src/sys/sys/linker.h,v retrieving revision 1.31 diff -u -r1.31 linker.h --- sys/linker.h 2 Aug 2002 20:56:06 -0000 1.31 +++ sys/linker.h 27 Sep 2002 04:22:29 -0000 @@ -230,6 +230,7 @@ /* Support functions */ int elf_reloc(linker_file_t _lf, const void *_rel, int _type); Elf_Addr elf_lookup(linker_file_t, Elf_Word, int); +const Elf_Sym *elf_get_sym(linker_file_t _lf, Elf_Word _symidx); /* values for type */ #define ELF_RELOC_REL 1