Move elf class marker figuring to helper function, generalize a bit

- Determine arch-specific issues by looking at the elf header instead
  of compile-time #ifdefs, so we'll generate correct dependencies for
  non-native elf binaries too. Currently this is just alpha which despite
  being a 64bit system, never had the (64bit) markers in its dependencies.
  Of course alpha has pretty much already met its mark^H^H er maker by now,
  but doing the right thing is cheap... Also we'll need similar special
  cases sooner or later for other archs (such as x32).
This commit is contained in:
Panu Matilainen 2013-01-03 12:59:13 +02:00
parent e7489abd66
commit f84a71cdc7
1 changed files with 19 additions and 5 deletions

View File

@ -35,6 +35,24 @@ static int skipPrivate(const char *s)
return (filter_private && rstreq(s, "GLIBC_PRIVATE"));
}
static const char *mkmarker(GElf_Ehdr *ehdr)
{
const char *marker = NULL;
if (ehdr->e_ident[EI_CLASS] == ELFCLASS64) {
switch (ehdr->e_machine) {
case EM_ALPHA:
case EM_FAKE_ALPHA:
/* alpha doesn't traditionally have 64bit markers */
break;
default:
marker = "(64bit)";
break;
}
}
return marker;
}
static void addDep(ARGV_t *deps,
const char *soname, const char *ver, const char *marker)
{
@ -220,11 +238,7 @@ static int processFile(const char *fn, int dtype)
goto exit;
if (ehdr->e_type == ET_DYN || ehdr->e_type == ET_EXEC) {
/* on alpha, everything is 64bit but we dont want the (64bit) markers */
#if !defined(__alpha__)
if (ehdr->e_ident[EI_CLASS] == ELFCLASS64)
ei->marker = "(64bit)";
#endif
ei->marker = mkmarker(ehdr);
ei->isDSO = (ehdr->e_type == ET_DYN);
ei->isExec = (st.st_mode & (S_IXUSR|S_IXGRP|S_IXOTH));