Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 314191 Details for
Bug 452194
elfutils incorrectly reports assembler symbols
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
Proposed patch for bugs 268961 and 452194
1.patch (text/plain), 8.90 KB, created by
Denys Vlasenko
on 2008-08-13 11:18:51 UTC
(
hide
)
Description:
Proposed patch for bugs 268961 and 452194
Filename:
MIME Type:
Creator:
Denys Vlasenko
Created:
2008-08-13 11:18:51 UTC
Size:
8.90 KB
patch
obsolete
>diff -d -urpN -U8 elfutils.0/libdwfl/dwfl_module_addrsym.c elfutils.1/libdwfl/dwfl_module_addrsym.c >--- elfutils.0/libdwfl/dwfl_module_addrsym.c 2008-07-15 14:39:07.000000000 +0200 >+++ elfutils.1/libdwfl/dwfl_module_addrsym.c 2008-08-13 12:44:23.000000000 +0200 >@@ -44,37 +44,41 @@ > Open Invention Network licensees cross-license their patents. No patent > license is granted, either expressly or impliedly, by designation as an > included package. Should you wish to participate in the Open Invention > Network licensing program, please visit www.openinventionnetwork.com > <http://www.openinventionnetwork.com>. */ > > #include "libdwflP.h" > >+/* Returns the name of the symbol "closest" to ADDR. >+ Never returns symbols which are above ADDR, only at or below. */ >+ > const char * > dwfl_module_addrsym (Dwfl_Module *mod, GElf_Addr addr, > GElf_Sym *closest_sym, GElf_Word *shndxp) > { > int syments = INTUSE(dwfl_module_getsymtab) (mod); > if (syments < 0) > return NULL; > > /* Return true iff we consider ADDR to lie in the same section as SYM. */ > GElf_Word addr_shndx = SHN_UNDEF; >- inline bool same_section (const GElf_Sym *sym, GElf_Word shndx) >+ inline bool same_section_as_addr (const GElf_Sym *sym, GElf_Word shndx) > { > /* For absolute symbols and the like, only match exactly. */ > if (shndx >= SHN_LORESERVE) > return sym->st_value == addr; > > /* Ignore section and other special symbols. */ > switch (GELF_ST_TYPE (sym->st_info)) > { >- case STT_SECTION: >- case STT_FILE: >+ /* Can't happen, caller filters these out: */ >+ /* case STT_SECTION: */ >+ /* case STT_FILE: */ > case STT_TLS: > return false; > } > > /* Figure out what section ADDR lies in. */ > if (addr_shndx == SHN_UNDEF) > { > GElf_Addr mod_addr = addr - mod->symfile->bias; >@@ -103,73 +107,75 @@ dwfl_module_addrsym (Dwfl_Module *mod, G > GElf_Word closest_shndx = SHN_UNDEF; > > /* Keep track of an eligible symbol with st_size == 0 as a fallback. */ > const char *sizeless_name = NULL; > GElf_Sym sizeless_sym = { 0, 0, 0, 0, 0, SHN_UNDEF }; > GElf_Word sizeless_shndx = SHN_UNDEF; > > /* Keep track of the lowest address a relevant sizeless symbol could have. */ >- GElf_Addr min_label = addr; >+ GElf_Addr min_label = 0; > > /* Look through the symbol table for a matching symbol. */ > for (int i = 1; i < syments; ++i) > { > GElf_Sym sym; > GElf_Word shndx; > const char *name = INTUSE(dwfl_module_getsym) (mod, i, &sym, &shndx); >- if (name != NULL >- && sym.st_value <= addr >- && (sym.st_size == 0 || addr - sym.st_value < sym.st_size)) >- { >- /* Even if we don't choose this symbol, its existence >- excludes any sizeless symbol (assembly label) that >- is inside its bounds. */ >- if (sym.st_value + sym.st_size > addr) >- min_label = sym.st_value + sym.st_size; >+ if (name == NULL || name[0] == '\0' || sym.st_value > addr) >+ continue; >+ /* Section and file symbols are excluded too. */ >+ if (GELF_ST_TYPE (sym.st_info) == STT_SECTION >+ || GELF_ST_TYPE (sym.st_info) == STT_FILE) >+ continue; >+ >+ /* Even if we don't choose this symbol, its existence excludes >+ any sizeless symbol (assembly label) that is below its upper >+ bound. */ >+ if (sym.st_value + sym.st_size > min_label) >+ min_label = sym.st_value + sym.st_size; > >+ if (sym.st_size == 0 || addr - sym.st_value < sym.st_size) >+ { > /* This symbol is a better candidate than the current one >- if it's a named symbol, not a section or file symbol, >- and is closer to ADDR or is global when it was local. */ >- if (name[0] != '\0' >- && GELF_ST_TYPE (sym.st_info) != STT_SECTION >- && GELF_ST_TYPE (sym.st_info) != STT_FILE) >+ if it's closer to ADDR or is global when it was local. */ >+ if (closest_name == NULL >+ || closest_sym->st_value < sym.st_value >+ || (GELF_ST_BIND (closest_sym->st_info) >+ < GELF_ST_BIND (sym.st_info))) > { >- if (closest_name == NULL >- || closest_sym->st_value < sym.st_value >- || (GELF_ST_BIND (closest_sym->st_info) >- < GELF_ST_BIND (sym.st_info))) >- { >- if (sym.st_size != 0) >- { >- *closest_sym = sym; >- closest_shndx = shndx; >- closest_name = name; >- } >- else if (same_section (&sym, shndx)) >- { >- /* Handwritten assembly symbols sometimes have no >- st_size. If no symbol with proper size includes >- the address, we'll use the closest one that is in >- the same section as ADDR. */ >- sizeless_sym = sym; >- sizeless_shndx = shndx; >- sizeless_name = name; >- } >- } >- /* When the beginning of its range is no closer, >- the end of its range might be. */ >- else if (sym.st_size != 0 >- && closest_sym->st_value == sym.st_value >- && closest_sym->st_size > sym.st_size) >+ if (sym.st_size != 0) > { > *closest_sym = sym; > closest_shndx = shndx; > closest_name = name; > } >+ else if (same_section_as_addr (&sym, shndx)) >+ { >+ /* Handwritten assembly symbols sometimes have no >+ st_size. If no symbol with proper size includes >+ the address, we'll use the closest one that is in >+ the same section as ADDR. */ >+ sizeless_sym = sym; >+ sizeless_shndx = shndx; >+ sizeless_name = name; >+ } >+ } >+ /* When the beginning of its range is no closer, >+ the end of its range might be. But do not >+ replace global symbol with 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 = sym; >+ closest_shndx = shndx; >+ closest_name = name; > } > } > } > > /* If we found no proper sized symbol to use, fall back to the best > candidate sizeless symbol we found, if any. */ > if (closest_name == NULL > && sizeless_name != NULL && sizeless_sym.st_value >= min_label) >diff -d -urpN -U8 elfutils.0/tests/Makefile.am elfutils.1/tests/Makefile.am >--- elfutils.0/tests/Makefile.am 2008-07-15 14:39:07.000000000 +0200 >+++ elfutils.1/tests/Makefile.am 2008-08-13 12:59:51.000000000 +0200 >@@ -134,17 +134,18 @@ EXTRA_DIST = run-arextract.sh run-arsymt > testfile30.bz2 testfile31.bz2 testfile32.bz2 testfile33.bz2 \ > testfile34.bz2 testfile35.bz2 testfile35.debug.bz2 \ > testfile36.bz2 testfile36.debug.bz2 \ > testfile37.bz2 testfile37.debug.bz2 \ > testfile38.bz2 testfile39.bz2 testfile40.bz2 testfile40.debug.bz2 \ > testfile41.bz2 testfile42.bz2 testfile43.bz2 \ > testfile44.S.bz2 testfile44.expect.bz2 run-disasm-x86.sh \ > testfile45.S.bz2 testfile45.expect.bz2 run-disasm-x86-64.sh \ >- testfile46.bz2 testfile47.bz2 testfile48.bz2 testfile48.debug.bz2 >+ testfile46.bz2 testfile47.bz2 testfile48.bz2 testfile48.debug.bz2 \ >+ testfile50.o.bz2 testfile51.o.bz2 > > installed_TESTS_ENVIRONMENT = libdir=$(DESTDIR)$(libdir) \ > bindir=$(DESTDIR)$(bindir) \ > $(srcdir)/test-wrapper.sh \ > installed $(tests_rpath) \ > $(program_transform_name) > if STANDALONE > TESTS_ENVIRONMENT = $(installed_TESTS_ENVIRONMENT) >diff -d -urpN -U8 elfutils.0/tests/run-addrname-test.sh elfutils.1/tests/run-addrname-test.sh >--- elfutils.0/tests/run-addrname-test.sh 2008-07-15 14:39:07.000000000 +0200 >+++ elfutils.1/tests/run-addrname-test.sh 2008-08-13 13:14:42.000000000 +0200 >@@ -79,9 +79,74 @@ EOF > > testrun_compare ../src/addr2line -S -M testmaps 0x40047c 0x10009db <<\EOF > caller+0x14 > /home/drepper/local/elfutils-build/20050425/v.c:11 > foo+0xb > /home/drepper/local/elfutils-build/20030710/u.c:5 > EOF > >+# .section .text >+# nop #0 >+#sizeless_foo: >+# nop #1 >+# nop #2 >+#sized_bar: >+# nop #3 >+#sizeless_baz: >+# nop #4 >+# .size sized_bar, . - sized_bar >+# nop #5 >+#sizeless_x: >+# nop #6 >+testfiles testfile50.o >+testrun_compare ../src/addr2line -S -e testfile50.o 0 1 2 3 4 5 6 <<\EOF >+(.text)+0z >+??:0 >+sizeless_foo >+??:0 >+sizeless_foo+0x1 >+??:0 >+sized_bar >+??:0 >+sized_bar+0x1 >+??:0 >+(.text)+0x5 >+??:0 >+sizeless_x >+??:0 >+EOF >+ >+# nop #0 >+# .globl global_outer >+#global_outer: >+# nop #1 >+# .globl global_in_global >+#global_in_global: >+# nop #2 >+# .size global_in_global, . - global_in_global >+#local_in_global: >+# nop #3 >+# .size local_in_global, . - local_in_global >+# nop #4 >+#.Lsizeless: >+# nop #5 >+# .size global_outer, . - global_outer >+# nop #6 >+testfiles testfile51.o >+testrun_compare ../src/addr2line -S -e testfile51.o 0 1 2 3 4 5 6 <<\EOF >+(.text)+0 >+??:0 >+global_outer >+??:0 >+global_in_global >+??:0 >+global_outer+0x2 >+??:0 >+global_outer+0x3 >+??:0 >+global_outer+0x4 >+??:0 >+(.text)+0x6 >+??:0 >+EOF >+ > exit 0 >Binary files elfutils.0/tests/testfile50.o.bz2 and elfutils.1/tests/testfile50.o.bz2 differ >Binary files elfutils.0/tests/testfile51.o.bz2 and elfutils.1/tests/testfile51.o.bz2 differ
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 452194
:
309892
| 314191 |
314192
|
314194