This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
FYI: use accessor in solib-svr4.c
- From: Tom Tromey <tromey at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Thu, 13 Dec 2012 14:29:31 -0700
- Subject: FYI: use accessor in solib-svr4.c
I'm checking this in.
While working on another patch I noticed that solib-svr4.c is directly
using objfile::sect_index_text.
It is better to use the accessor, because it checks for an invalid
value. This is especially important when passing it to ANOFFSET,
because using an invalid value there means that gdb would silently
underflow an array's bounds.
I think this is the only invalid use in gdb. I also checked the other
sect_index_* fields.
Built and regtested on x86-64 Fedora 16.
Tom
2012-12-13 Tom Tromey <tromey@redhat.com>
* solib-svr4.c (enable_break): Use SECT_OFF_TEXT.
Index: solib-svr4.c
===================================================================
RCS file: /cvs/src/src/gdb/solib-svr4.c,v
retrieving revision 1.170
diff -u -r1.170 solib-svr4.c
--- solib-svr4.c 10 Dec 2012 16:42:17 -0000 1.170
+++ solib-svr4.c 13 Dec 2012 21:24:54 -0000
@@ -1504,7 +1504,7 @@
tmp_bfd = os->objfile->obfd;
load_addr = ANOFFSET (os->objfile->section_offsets,
- os->objfile->sect_index_text);
+ SECT_OFF_TEXT (os->objfile));
interp_sect = bfd_get_section_by_name (tmp_bfd, ".text");
if (interp_sect)