[patch] Improve ELF symbols preference (global > weak)

Jan Kratochvil jan.kratochvil at redhat.com
Mon Oct 8 18:54:57 UTC 2012


Hi,

sorry, forgot a ChangeLog:


libdwfl/
2012-10-08  Jan Kratochvil  <jan.kratochvil at redhat.com>

	* dwfl_module_addrsym.c (dwfl_module_addrsym): Prefer also STB_WEAK
	over STB_LOCAL.

diff --git a/libdwfl/dwfl_module_addrsym.c b/libdwfl/dwfl_module_addrsym.c
index 4e0646e..7ea6289 100644
--- a/libdwfl/dwfl_module_addrsym.c
+++ b/libdwfl/dwfl_module_addrsym.c
@@ -133,13 +143,13 @@ dwfl_module_addrsym (Dwfl_Module *mod, GElf_Addr addr,
 			}
 		    }
 		  /* When the beginning of its range is no closer,
-		     the end of its range might be.  But do not
-		     replace a global symbol with a local!  */
+		     the end of its range might be.  Prefer STB_GLOBAL over
+		     STB_WEAK and STB_WEAK over STB_LOCAL.  */
 		  else if (sym.st_size != 0
 			   && closest_sym->st_value == sym.st_value
-			   && closest_sym->st_size > sym.st_size
-			   && (GELF_ST_BIND (closest_sym->st_info)
-			       <= GELF_ST_BIND (sym.st_info)))
+			   && closest_sym->st_size >= sym.st_size
+			   && (GELF_ST_BIND (sym.st_info) == STB_GLOBAL
+			    || GELF_ST_BIND (closest_sym->st_info) == STB_LOCAL))
 		    {
 		      *closest_sym = sym;
 		      closest_shndx = shndx;


More information about the elfutils-devel mailing list