public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
* [binutils-gdb] Re: objdump read_section_stabs
@ 2023-02-21 23:02 Alan Modra
  0 siblings, 0 replies; 2+ messages in thread
From: Alan Modra @ 2023-02-21 23:02 UTC (permalink / raw)
  To: bfd-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=45b36294d60e3c72c32f8003b82ee852672f1948

commit 45b36294d60e3c72c32f8003b82ee852672f1948
Author: Alan Modra <amodra@gmail.com>
Date:   Wed Feb 22 09:04:57 2023 +1030

    Re: objdump read_section_stabs
    
    Commit f9c36cc99518 changed (and renamed) read_section_stabs with one
    difference in overall behaviour.  Previously read_section_stabs would
    return a NULL for an empty section, which was then treated the same as
    a missing section.  Now an empty section is recognized and dumped.
    This leads to NULL stabp and stabs_end in print_section_stabs.  Since
    stabs_end - STABSIZE is then a pointer to a very large address, the
    test "stabp < stabs_end - STABSIZE" succeeds.
    
            * objdump.c (print_section_stabs): Correct STABSIZE comparison.

Diff:
---
 binutils/objdump.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/binutils/objdump.c b/binutils/objdump.c
index 984c7219a0c..40ed6882b45 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -4508,7 +4508,7 @@ print_section_stabs (bfd *abfd,
 
      We start the index at -1 because there is a dummy symbol on
      the front of stabs-in-{coff,elf} sections that supplies sizes.  */
-  for (i = -1; stabp <= stabs_end - STABSIZE; stabp += STABSIZE, i++)
+  for (i = -1; (size_t) (stabs_end - stabp) >= STABSIZE; stabp += STABSIZE, i++)
     {
       const char *name;
       unsigned long strx;

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [binutils-gdb] Re: objdump read_section_stabs
@ 2023-02-21 23:35 Alan Modra
  0 siblings, 0 replies; 2+ messages in thread
From: Alan Modra @ 2023-02-21 23:35 UTC (permalink / raw)
  To: bfd-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c65f94a07aee0c1c6745e079a613f2fefa79a657

commit c65f94a07aee0c1c6745e079a613f2fefa79a657
Author: Alan Modra <amodra@gmail.com>
Date:   Wed Feb 22 09:57:53 2023 +1030

    Re: objdump read_section_stabs
    
    Also fix ubsan "applying zero offset to null pointer".
    
            * objdump.c (print_section_stabs): Avoid ubsan warning.

Diff:
---
 binutils/objdump.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/binutils/objdump.c b/binutils/objdump.c
index 40ed6882b45..d00eed054c4 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -4499,7 +4499,7 @@ print_section_stabs (bfd *abfd,
   bfd_byte *stabp, *stabs_end;
 
   stabp = stabs;
-  stabs_end = stabp + stab_size;
+  stabs_end = PTR_ADD (stabp, stab_size);
 
   printf (_("Contents of %s section:\n\n"), sanitize_string (stabsect_name));
   printf ("Symnum n_type n_othr n_desc n_value  n_strx String\n");

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-02-21 23:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-21 23:02 [binutils-gdb] Re: objdump read_section_stabs Alan Modra
2023-02-21 23:35 Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).