version 1.10, 2004/10/09 20:26:57 |
version 1.11, 2004/10/10 16:41:18 |
|
|
#define ELF_SBSS ".sbss" |
#define ELF_SBSS ".sbss" |
#define ELF_PLT ".plt" |
#define ELF_PLT ".plt" |
|
|
|
#ifndef SHN_MIPS_ACOMMON |
|
#define SHN_MIPS_ACOMMON SHN_LOPROC + 0 |
|
#endif |
|
#ifndef SHN_MIPS_TEXT |
|
#define SHN_MIPS_TEXT SHN_LOPROC + 1 |
|
#endif |
|
#ifndef SHN_MIPS_DATA |
|
#define SHN_MIPS_DATA SHN_LOPROC + 2 |
|
#endif |
|
#ifndef SHN_MIPS_SUNDEFINED |
|
#define SHN_MIPS_SUNDEFINED SHN_LOPROC + 4 |
|
#endif |
|
#ifndef SHN_MIPS_SCOMMON |
|
#define SHN_MIPS_SCOMMON SHN_LOPROC + 3 |
|
#endif |
|
|
|
#ifndef STT_PARISC_MILLI |
|
#define STT_PARISC_MILLI STT_LOPROC + 0 |
|
#endif |
|
|
int |
int |
elf_fix_header(Elf_Ehdr *eh) |
elf_fix_header(Elf_Ehdr *eh) |
{ |
{ |
|
|
} |
} |
|
|
int |
int |
elf_shn2type(u_int shn, const char *sn) |
elf_shn2type(Elf_Ehdr *eh, u_int shn, const char *sn) |
{ |
{ |
switch (shn) { |
switch (shn) { |
#ifdef SHN_MIPS_SUNDEFINED |
|
case SHN_MIPS_SUNDEFINED: |
case SHN_MIPS_SUNDEFINED: |
#endif |
if (eh->e_machine == EM_MIPS) |
|
return (N_UNDF | N_EXT); |
|
break; |
|
|
case SHN_UNDEF: |
case SHN_UNDEF: |
return (N_UNDF | N_EXT); |
return (N_UNDF | N_EXT); |
|
|
case SHN_ABS: |
case SHN_ABS: |
return (N_ABS); |
return (N_ABS); |
#ifdef SHN_MIPS_ACOMMON |
|
case SHN_MIPS_ACOMMON: |
case SHN_MIPS_ACOMMON: |
#endif |
if (eh->e_machine == EM_MIPS) |
#ifdef SHN_MIPS_SCOMMON |
return (N_COMM); |
|
break; |
|
|
case SHN_MIPS_SCOMMON: |
case SHN_MIPS_SCOMMON: |
#endif |
if (eh->e_machine == EM_MIPS) |
|
return (N_COMM); |
|
break; |
|
|
case SHN_COMMON: |
case SHN_COMMON: |
return (N_COMM); |
return (N_COMM); |
#ifdef SHN_MIPS_TEXT |
|
case SHN_MIPS_TEXT: |
case SHN_MIPS_TEXT: |
return (N_TEXT); |
if (eh->e_machine == EM_MIPS) |
#endif |
return (N_TEXT); |
#ifdef SHN_MIPS_DATA |
break; |
|
|
case SHN_MIPS_DATA: |
case SHN_MIPS_DATA: |
return (N_DATA); |
if (eh->e_machine == EM_MIPS) |
#endif |
return (N_DATA); |
|
break; |
|
|
default: |
default: |
/* beyond 8 a table-driven binsearch shall be used */ |
/* beyond 8 a table-driven binsearch shall be used */ |
if (sn == NULL) |
if (sn == NULL) |
|
|
return (N_DATA); |
return (N_DATA); |
else if (!strncmp(sn, ELF_PLT, sizeof(ELF_PLT) - 1)) |
else if (!strncmp(sn, ELF_PLT, sizeof(ELF_PLT) - 1)) |
return (N_DATA); |
return (N_DATA); |
return (-1); |
|
} |
} |
|
|
|
return (-1); |
} |
} |
|
|
/* |
/* |
|
|
switch (stt = ELF_ST_TYPE(sym->st_info)) { |
switch (stt = ELF_ST_TYPE(sym->st_info)) { |
case STT_NOTYPE: |
case STT_NOTYPE: |
case STT_OBJECT: |
case STT_OBJECT: |
type = elf_shn2type(sym->st_shndx, sn); |
type = elf_shn2type(eh, sym->st_shndx, sn); |
if (type < 0) { |
if (type < 0) { |
if (sn == NULL) |
if (sn == NULL) |
np->n_other = '?'; |
np->n_other = '?'; |
|
|
break; |
break; |
|
|
case STT_FUNC: |
case STT_FUNC: |
type = elf_shn2type(sym->st_shndx, NULL); |
type = elf_shn2type(eh, sym->st_shndx, NULL); |
np->n_type = type < 0? N_TEXT : type; |
np->n_type = type < 0? N_TEXT : type; |
if (ELF_ST_BIND(sym->st_info) == STB_WEAK) { |
if (ELF_ST_BIND(sym->st_info) == STB_WEAK) { |
np->n_type = N_INDR; |
np->n_type = N_INDR; |
|
|
break; |
break; |
|
|
case STT_SECTION: |
case STT_SECTION: |
type = elf_shn2type(sym->st_shndx, NULL); |
type = elf_shn2type(eh, sym->st_shndx, NULL); |
if (type < 0) |
if (type < 0) |
np->n_other = '?'; |
np->n_other = '?'; |
else |
else |
|
|
np->n_type = N_FN | N_EXT; |
np->n_type = N_FN | N_EXT; |
break; |
break; |
|
|
/* XXX how about cross-nm then ? */ |
|
#ifdef STT_PARISC_MILLI |
|
case STT_PARISC_MILLI: |
case STT_PARISC_MILLI: |
np->n_type = N_TEXT; |
if (eh->e_machine == EM_PARISC) |
|
np->n_type = N_TEXT; |
|
else |
|
np->n_other = '?'; |
break; |
break; |
#endif |
|
default: |
default: |
np->n_other = '?'; |
np->n_other = '?'; |
break; |
break; |