From f84a71cdc786a012fc9cbe16c5236c622ea970a4 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Thu, 3 Jan 2013 12:59:13 +0200 Subject: [PATCH] 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). --- tools/elfdeps.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/tools/elfdeps.c b/tools/elfdeps.c index e501f1764..65ef4f511 100644 --- a/tools/elfdeps.c +++ b/tools/elfdeps.c @@ -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));