public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Kristen Carlson Accardi <kristen@linux.intel.com>
To: Josh Poimboeuf <jpoimboe@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>
Cc: Kristen Carlson Accardi <kristen@linux.intel.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH] objtool: support symtab_shndx during dump
Date: Wed, 12 Aug 2020 10:57:11 -0700	[thread overview]
Message-ID: <20200812175712.9462-1-kristen@linux.intel.com> (raw)

When getting the symbol index number, make sure to use the
extended symbol table information in order to support symbol
index's greater than 64K.

Signed-off-by: Kristen Carlson Accardi <kristen@linux.intel.com>
---
 tools/objtool/orc_dump.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/tools/objtool/orc_dump.c b/tools/objtool/orc_dump.c
index fca46e006fc2..cf835069724a 100644
--- a/tools/objtool/orc_dump.c
+++ b/tools/objtool/orc_dump.c
@@ -74,7 +74,8 @@ int orc_dump(const char *_objname)
 	GElf_Rela rela;
 	GElf_Sym sym;
 	Elf_Data *data, *symtab = NULL, *rela_orc_ip = NULL;
-
+	Elf_Data *xsymtab = NULL;
+	Elf32_Word shndx;
 
 	objname = _objname;
 
@@ -138,6 +139,8 @@ int orc_dump(const char *_objname)
 			orc_ip_addr = sh.sh_addr;
 		} else if (!strcmp(name, ".rela.orc_unwind_ip")) {
 			rela_orc_ip = data;
+		} else if (!strcmp(name, ".symtab_shndx")) {
+			xsymtab = data;
 		}
 	}
 
@@ -157,13 +160,22 @@ int orc_dump(const char *_objname)
 				return -1;
 			}
 
-			if (!gelf_getsym(symtab, GELF_R_SYM(rela.r_info), &sym)) {
-				WARN_ELF("gelf_getsym");
+			if (!gelf_getsymshndx(symtab, xsymtab,
+					      GELF_R_SYM(rela.r_info),
+					      &sym, &shndx)) {
+				WARN_ELF("gelf_getsymshndx");
 				return -1;
 			}
 
 			if (GELF_ST_TYPE(sym.st_info) == STT_SECTION) {
-				scn = elf_getscn(elf, sym.st_shndx);
+				if ((sym.st_shndx > SHN_UNDEF &&
+				     sym.st_shndx < SHN_LORESERVE) ||
+				    (xsymtab && sym.st_shndx == SHN_XINDEX)) {
+					if (sym.st_shndx != SHN_XINDEX)
+						shndx = sym.st_shndx;
+				}
+
+				scn = elf_getscn(elf, shndx);
 				if (!scn) {
 					WARN_ELF("elf_getscn");
 					return -1;
-- 
2.20.1


             reply	other threads:[~2020-08-12 17:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-12 17:57 Kristen Carlson Accardi [this message]
2020-09-03 11:43 ` [PATCH] objtool: support symtab_shndx during dump Miroslav Benes
2020-09-03 15:35 ` Josh Poimboeuf
2020-09-04  7:54   ` Miroslav Benes
2020-09-04 14:17     ` Josh Poimboeuf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200812175712.9462-1-kristen@linux.intel.com \
    --to=kristen@linux.intel.com \
    --cc=jpoimboe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox