[PATCH] objdump: Use the SEC_CODE bit only for the section symbol

H.J. Lu hjl.tools@gmail.com
Mon Sep 8 22:24:59 GMT 2025


.got section on Powerpc contains both code and data:

Disassembly of section .got:

000101f0 <.got>:
   101f0:	02 00 00 00 	.long 0x2
	...
   10200:	21 00 80 4e 	blrl

00010204 <_GLOBAL_OFFSET_TABLE_>:
   10204:	70 01 01 00 00 00 00 00 00 00 00 00                 p...........

Use the SEC_CODE bit only if the symbol address matches the section start
address:

Disassembly of section .plt:

00000000000002c0 <_PROCEDURE_LINKAGE_TABLE_>:
 2c0:	ff 35 7a 01 10 00    	push   0x10017a(%rip)        # 100440 <_GLOBAL_OFFSET_TABLE_+0x8>
 2c6:	ff 25 7c 01 10 00    	jmp    *0x10017c(%rip)        # 100448 <_GLOBAL_OFFSET_TABLE_+0x10>
 2cc:	0f 1f 40 00          	nopl   0x0(%rax)

00000000000002d0 <foo@plt>:
 2d0:	ff 25 7a 01 10 00    	jmp    *0x10017a(%rip)        # 100450 <foo>
 2d6:	68 00 00 00 00       	push   $0x0
 2db:	e9 e0 ff ff ff       	jmp    2c0 <_PROCEDURE_LINKAGE_TABLE_>

	PR binutils/33389
	* objdump.c (disassemble_section): Use the SEC_CODE bit only if
	the symbol address matches the section start address.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
---
 binutils/objdump.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/binutils/objdump.c b/binutils/objdump.c
index d322775e72d..5590182e77f 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -4091,7 +4091,8 @@ disassemble_section (bfd *abfd, asection *section, void *inf)
       if (disassemble_all
 	  || sym == NULL
 	  || sym->section != section
-	  || (section->flags & SEC_CODE) != 0
+	  || ((section->flags & SEC_CODE) != 0
+	      && bfd_asymbol_value (sym) == section->vma)
 	  || bfd_asymbol_value (sym) > addr
 	  || ((sym->flags & BSF_OBJECT) == 0
 	      && (strstr (bfd_asymbol_name (sym), "gnu_compiled")
-- 
2.51.0



More information about the Binutils mailing list