From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13792 invoked by alias); 12 Jun 2003 21:19:36 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 13751 invoked from network); 12 Jun 2003 21:19:35 -0000 Received: from unknown (HELO zenia.home) (12.223.225.216) by sources.redhat.com with SMTP; 12 Jun 2003 21:19:35 -0000 Received: by zenia.home (Postfix, from userid 5433) id D007C20D85; Thu, 12 Jun 2003 16:19:45 -0500 (EST) To: gdb-patches@sources.redhat.com Subject: RFA: solib: select symbols based on section flags From: Jim Blandy Date: Thu, 12 Jun 2003 21:19:00 -0000 Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2003-06/txt/msg00430.txt.bz2 2003-06-11 Jim Blandy * solib-svr4.c (bfd_lookup_symbol): New SECT_FLAGS argument. (enable_break): Pass SEC_CODE as the SECT_FLAGS argument to bfd_lookup_symbol, since we only want symbols in code sections. (look_for_base): Pass zero as the SECT_FLAGS argument to bfd_lookup_symbol, since we're not concerned about which section the symbol is in. Index: gdb/solib-svr4.c =================================================================== RCS file: /cvs/src/src/gdb/solib-svr4.c,v retrieving revision 1.33 diff -c -r1.33 solib-svr4.c *** gdb/solib-svr4.c 1 Jun 2003 23:00:55 -0000 1.33 --- gdb/solib-svr4.c 11 Jun 2003 08:44:51 -0000 *************** *** 166,172 **** static int match_main (char *); ! static CORE_ADDR bfd_lookup_symbol (bfd *, char *); /* --- 166,172 ---- static int match_main (char *); ! static CORE_ADDR bfd_lookup_symbol (bfd *, char *, flagword); /* *************** *** 176,182 **** SYNOPSIS ! CORE_ADDR bfd_lookup_symbol (bfd *abfd, char *symname) DESCRIPTION --- 176,182 ---- SYNOPSIS ! CORE_ADDR bfd_lookup_symbol (bfd *abfd, char *symname, flagword sect_flags) DESCRIPTION *************** *** 185,196 **** shared library support to find the address of the debugger interface structures in the shared library. Note that 0 is specifically allowed as an error return (no such symbol). */ static CORE_ADDR ! bfd_lookup_symbol (bfd *abfd, char *symname) { long storage_needed; asymbol *sym; --- 185,199 ---- shared library support to find the address of the debugger interface structures in the shared library. + If SECT_FLAGS is non-zero, only match symbols in sections whose + flags include all those in SECT_FLAGS. + Note that 0 is specifically allowed as an error return (no such symbol). */ static CORE_ADDR ! bfd_lookup_symbol (bfd *abfd, char *symname, flagword sect_flags) { long storage_needed; asymbol *sym; *************** *** 211,217 **** for (i = 0; i < number_of_symbols; i++) { sym = *symbol_table++; ! if (STREQ (sym->name, symname)) { /* Bfd symbols are section relative. */ symaddr = sym->value + sym->section->vma; --- 214,221 ---- for (i = 0; i < number_of_symbols; i++) { sym = *symbol_table++; ! if (STREQ (sym->name, symname) ! && (sym->section->flags & sect_flags) == sect_flags) { /* Bfd symbols are section relative. */ symaddr = sym->value + sym->section->vma; *************** *** 238,244 **** for (i = 0; i < number_of_symbols; i++) { sym = *symbol_table++; ! if (STREQ (sym->name, symname)) { /* Bfd symbols are section relative. */ symaddr = sym->value + sym->section->vma; --- 242,250 ---- for (i = 0; i < number_of_symbols; i++) { sym = *symbol_table++; ! ! if (STREQ (sym->name, symname) ! && (sym->section->flags & sect_flags) == sect_flags) { /* Bfd symbols are section relative. */ symaddr = sym->value + sym->section->vma; *************** *** 344,350 **** for (symbolp = debug_base_symbols; *symbolp != NULL; symbolp++) { ! address = bfd_lookup_symbol (interp_bfd, *symbolp); if (address != 0) { break; --- 350,356 ---- for (symbolp = debug_base_symbols; *symbolp != NULL; symbolp++) { ! address = bfd_lookup_symbol (interp_bfd, *symbolp, 0); if (address != 0) { break; *************** *** 1049,1055 **** /* Now try to set a breakpoint in the dynamic linker. */ for (bkpt_namep = solib_break_names; *bkpt_namep != NULL; bkpt_namep++) { ! sym_addr = bfd_lookup_symbol (tmp_bfd, *bkpt_namep); if (sym_addr != 0) break; } --- 1055,1070 ---- /* Now try to set a breakpoint in the dynamic linker. */ for (bkpt_namep = solib_break_names; *bkpt_namep != NULL; bkpt_namep++) { ! /* On ABI's that use function descriptors, there are usually ! two linker symbols associated with each C function: one ! pointing at the actual entry point of the machine code, ! and one pointing at the function's descriptor. The ! latter symbol has the same name as the C function. ! ! What we're looking for here is the machine code entry ! point, so we are only interested in symbols in code ! sections. */ ! sym_addr = bfd_lookup_symbol (tmp_bfd, *bkpt_namep, SEC_CODE); if (sym_addr != 0) break; }