|
@@ -288,6 +288,23 @@ int dso__synthesize_plt_symbols(struct dso *dso __maybe_unused,
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
+static int fd__is_64_bit(int fd)
|
|
|
+{
|
|
|
+ u8 e_ident[EI_NIDENT];
|
|
|
+
|
|
|
+ if (lseek(fd, 0, SEEK_SET))
|
|
|
+ return -1;
|
|
|
+
|
|
|
+ if (readn(fd, e_ident, sizeof(e_ident)) != sizeof(e_ident))
|
|
|
+ return -1;
|
|
|
+
|
|
|
+ if (memcmp(e_ident, ELFMAG, SELFMAG) ||
|
|
|
+ e_ident[EI_VERSION] != EV_CURRENT)
|
|
|
+ return -1;
|
|
|
+
|
|
|
+ return e_ident[EI_CLASS] == ELFCLASS64;
|
|
|
+}
|
|
|
+
|
|
|
int dso__load_sym(struct dso *dso, struct map *map __maybe_unused,
|
|
|
struct symsrc *ss,
|
|
|
struct symsrc *runtime_ss __maybe_unused,
|
|
@@ -295,6 +312,11 @@ int dso__load_sym(struct dso *dso, struct map *map __maybe_unused,
|
|
|
int kmodule __maybe_unused)
|
|
|
{
|
|
|
unsigned char *build_id[BUILD_ID_SIZE];
|
|
|
+ int ret;
|
|
|
+
|
|
|
+ ret = fd__is_64_bit(ss->fd);
|
|
|
+ if (ret >= 0)
|
|
|
+ dso->is_64_bit = ret;
|
|
|
|
|
|
if (filename__read_build_id(ss->name, build_id, BUILD_ID_SIZE) > 0) {
|
|
|
dso__set_build_id(dso, build_id);
|