15796c8dcSSimon Schubert /* Shared library declarations for GDB, the GNU Debugger. 2*ef5ccd6cSJohn Marino Copyright (C) 1990-2013 Free Software Foundation, Inc. 35796c8dcSSimon Schubert 45796c8dcSSimon Schubert This file is part of GDB. 55796c8dcSSimon Schubert 65796c8dcSSimon Schubert This program is free software; you can redistribute it and/or modify 75796c8dcSSimon Schubert it under the terms of the GNU General Public License as published by 85796c8dcSSimon Schubert the Free Software Foundation; either version 3 of the License, or 95796c8dcSSimon Schubert (at your option) any later version. 105796c8dcSSimon Schubert 115796c8dcSSimon Schubert This program is distributed in the hope that it will be useful, 125796c8dcSSimon Schubert but WITHOUT ANY WARRANTY; without even the implied warranty of 135796c8dcSSimon Schubert MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 145796c8dcSSimon Schubert GNU General Public License for more details. 155796c8dcSSimon Schubert 165796c8dcSSimon Schubert You should have received a copy of the GNU General Public License 175796c8dcSSimon Schubert along with this program. If not, see <http://www.gnu.org/licenses/>. */ 185796c8dcSSimon Schubert 195796c8dcSSimon Schubert #ifndef SOLIST_H 205796c8dcSSimon Schubert #define SOLIST_H 215796c8dcSSimon Schubert 225796c8dcSSimon Schubert #define SO_NAME_MAX_PATH_SIZE 512 /* FIXME: Should be dynamic */ 235796c8dcSSimon Schubert /* For domain_enum domain. */ 245796c8dcSSimon Schubert #include "symtab.h" 255796c8dcSSimon Schubert 265796c8dcSSimon Schubert /* Forward declaration for target specific link map information. This 275796c8dcSSimon Schubert struct is opaque to all but the target specific file. */ 285796c8dcSSimon Schubert struct lm_info; 295796c8dcSSimon Schubert 305796c8dcSSimon Schubert struct so_list 315796c8dcSSimon Schubert { 325796c8dcSSimon Schubert /* The following fields of the structure come directly from the 335796c8dcSSimon Schubert dynamic linker's tables in the inferior, and are initialized by 345796c8dcSSimon Schubert current_sos. */ 355796c8dcSSimon Schubert 365796c8dcSSimon Schubert struct so_list *next; /* next structure in linked list */ 375796c8dcSSimon Schubert 385796c8dcSSimon Schubert /* A pointer to target specific link map information. Often this 395796c8dcSSimon Schubert will be a copy of struct link_map from the user process, but 405796c8dcSSimon Schubert it need not be; it can be any collection of data needed to 415796c8dcSSimon Schubert traverse the dynamic linker's data structures. */ 425796c8dcSSimon Schubert struct lm_info *lm_info; 435796c8dcSSimon Schubert 445796c8dcSSimon Schubert /* Shared object file name, exactly as it appears in the 455796c8dcSSimon Schubert inferior's link map. This may be a relative path, or something 465796c8dcSSimon Schubert which needs to be looked up in LD_LIBRARY_PATH, etc. We use it 475796c8dcSSimon Schubert to tell which entries in the inferior's dynamic linker's link 485796c8dcSSimon Schubert map we've already loaded. */ 495796c8dcSSimon Schubert char so_original_name[SO_NAME_MAX_PATH_SIZE]; 505796c8dcSSimon Schubert 51c50c785cSJohn Marino /* Shared object file name, expanded to something GDB can open. */ 525796c8dcSSimon Schubert char so_name[SO_NAME_MAX_PATH_SIZE]; 535796c8dcSSimon Schubert 54cf7f2e2dSJohn Marino /* Program space this shared library belongs to. */ 55cf7f2e2dSJohn Marino struct program_space *pspace; 56cf7f2e2dSJohn Marino 575796c8dcSSimon Schubert /* The following fields of the structure are built from 585796c8dcSSimon Schubert information gathered from the shared object file itself, and 595796c8dcSSimon Schubert are set when we actually add it to our symbol tables. 605796c8dcSSimon Schubert 615796c8dcSSimon Schubert current_sos must initialize these fields to 0. */ 625796c8dcSSimon Schubert 635796c8dcSSimon Schubert bfd *abfd; 645796c8dcSSimon Schubert char symbols_loaded; /* flag: symbols read in yet? */ 65cf7f2e2dSJohn Marino 66cf7f2e2dSJohn Marino /* objfile with symbols for a loaded library. Target memory is read from 67cf7f2e2dSJohn Marino ABFD. OBJFILE may be NULL either before symbols have been loaded, if 68cf7f2e2dSJohn Marino the file cannot be found or after the command "nosharedlibrary". */ 69cf7f2e2dSJohn Marino struct objfile *objfile; 70cf7f2e2dSJohn Marino 715796c8dcSSimon Schubert struct target_section *sections; 725796c8dcSSimon Schubert struct target_section *sections_end; 735796c8dcSSimon Schubert 745796c8dcSSimon Schubert /* Record the range of addresses belonging to this shared library. 755796c8dcSSimon Schubert There may not be just one (e.g. if two segments are relocated 765796c8dcSSimon Schubert differently); but this is only used for "info sharedlibrary". */ 775796c8dcSSimon Schubert CORE_ADDR addr_low, addr_high; 785796c8dcSSimon Schubert }; 795796c8dcSSimon Schubert 805796c8dcSSimon Schubert struct target_so_ops 815796c8dcSSimon Schubert { 825796c8dcSSimon Schubert /* Adjust the section binding addresses by the base address at 835796c8dcSSimon Schubert which the object was actually mapped. */ 845796c8dcSSimon Schubert void (*relocate_section_addresses) (struct so_list *so, 855796c8dcSSimon Schubert struct target_section *); 865796c8dcSSimon Schubert 87c50c785cSJohn Marino /* Free the link map info and any other private data structures 88c50c785cSJohn Marino associated with a so_list entry. */ 895796c8dcSSimon Schubert void (*free_so) (struct so_list *so); 905796c8dcSSimon Schubert 915796c8dcSSimon Schubert /* Reset or free private data structures not associated with 925796c8dcSSimon Schubert so_list entries. */ 935796c8dcSSimon Schubert void (*clear_solib) (void); 945796c8dcSSimon Schubert 955796c8dcSSimon Schubert /* Target dependent code to run after child process fork. */ 96cf7f2e2dSJohn Marino void (*solib_create_inferior_hook) (int from_tty); 975796c8dcSSimon Schubert 98a45ae5f8SJohn Marino /* Do additional symbol handling, lookup, etc. after symbols for a 99a45ae5f8SJohn Marino shared object have been loaded in the usual way. This is 100a45ae5f8SJohn Marino called to do any system specific symbol handling that might be 101a45ae5f8SJohn Marino needed. */ 1025796c8dcSSimon Schubert void (*special_symbol_handling) (void); 1035796c8dcSSimon Schubert 104a45ae5f8SJohn Marino /* Construct a list of the currently loaded shared objects. This 105a45ae5f8SJohn Marino list does not include an entry for the main executable file. 106a45ae5f8SJohn Marino 107a45ae5f8SJohn Marino Note that we only gather information directly available from the 108a45ae5f8SJohn Marino inferior --- we don't examine any of the shared library files 109a45ae5f8SJohn Marino themselves. The declaration of `struct so_list' says which fields 110a45ae5f8SJohn Marino we provide values for. */ 1115796c8dcSSimon Schubert struct so_list *(*current_sos) (void); 1125796c8dcSSimon Schubert 113a45ae5f8SJohn Marino /* Find, open, and read the symbols for the main executable. If 114a45ae5f8SJohn Marino FROM_TTYP dereferences to a non-zero integer, allow messages to 115a45ae5f8SJohn Marino be printed. This parameter is a pointer rather than an int 116a45ae5f8SJohn Marino because open_symbol_file_object is called via catch_errors and 117a45ae5f8SJohn Marino catch_errors requires a pointer argument. */ 1185796c8dcSSimon Schubert int (*open_symbol_file_object) (void *from_ttyp); 1195796c8dcSSimon Schubert 1205796c8dcSSimon Schubert /* Determine if PC lies in the dynamic symbol resolution code of 121c50c785cSJohn Marino the run time loader. */ 1225796c8dcSSimon Schubert int (*in_dynsym_resolve_code) (CORE_ADDR pc); 1235796c8dcSSimon Schubert 1245796c8dcSSimon Schubert /* Find and open shared library binary file. */ 1255796c8dcSSimon Schubert bfd *(*bfd_open) (char *pathname); 1265796c8dcSSimon Schubert 1275796c8dcSSimon Schubert /* Extra hook for finding and opening a solib. 1285796c8dcSSimon Schubert Convenience function for remote debuggers finding host libs. */ 1295796c8dcSSimon Schubert int (*find_and_open_solib) (char *soname, 1305796c8dcSSimon Schubert unsigned o_flags, char **temp_pathname); 1315796c8dcSSimon Schubert 1325796c8dcSSimon Schubert /* Hook for looking up global symbols in a library-specific way. */ 1335796c8dcSSimon Schubert struct symbol * (*lookup_lib_global_symbol) (const struct objfile *objfile, 1345796c8dcSSimon Schubert const char *name, 1355796c8dcSSimon Schubert const domain_enum domain); 1365796c8dcSSimon Schubert 1375796c8dcSSimon Schubert /* Given two so_list objects, one from the GDB thread list 1385796c8dcSSimon Schubert and another from the list returned by current_sos, return 1 1395796c8dcSSimon Schubert if they represent the same library. 1405796c8dcSSimon Schubert Falls back to using strcmp on so_original_name field when set 1415796c8dcSSimon Schubert to NULL. */ 1425796c8dcSSimon Schubert int (*same) (struct so_list *gdb, struct so_list *inferior); 143cf7f2e2dSJohn Marino 144cf7f2e2dSJohn Marino /* Return whether a region of memory must be kept in a core file 145cf7f2e2dSJohn Marino for shared libraries loaded before "gcore" is used to be 146cf7f2e2dSJohn Marino handled correctly when the core file is loaded. This only 147cf7f2e2dSJohn Marino applies when the section would otherwise not be kept in the 148cf7f2e2dSJohn Marino core file (in particular, for readonly sections). */ 149cf7f2e2dSJohn Marino int (*keep_data_in_core) (CORE_ADDR vaddr, 150cf7f2e2dSJohn Marino unsigned long size); 1515796c8dcSSimon Schubert }; 1525796c8dcSSimon Schubert 1535796c8dcSSimon Schubert /* Free the memory associated with a (so_list *). */ 1545796c8dcSSimon Schubert void free_so (struct so_list *so); 1555796c8dcSSimon Schubert 1565796c8dcSSimon Schubert /* Return address of first so_list entry in master shared object list. */ 1575796c8dcSSimon Schubert struct so_list *master_so_list (void); 1585796c8dcSSimon Schubert 1595796c8dcSSimon Schubert /* Find shared library binary file. */ 1605796c8dcSSimon Schubert extern char *solib_find (char *in_pathname, int *fd); 1615796c8dcSSimon Schubert 1625796c8dcSSimon Schubert /* Open BFD for shared library file. */ 1635796c8dcSSimon Schubert extern bfd *solib_bfd_fopen (char *pathname, int fd); 1645796c8dcSSimon Schubert 1655796c8dcSSimon Schubert /* Find solib binary file and open it. */ 1665796c8dcSSimon Schubert extern bfd *solib_bfd_open (char *in_pathname); 1675796c8dcSSimon Schubert 168c50c785cSJohn Marino /* FIXME: gdbarch needs to control this variable. */ 1695796c8dcSSimon Schubert extern struct target_so_ops *current_target_so_ops; 1705796c8dcSSimon Schubert 1715796c8dcSSimon Schubert /* Handler for library-specific global symbol lookup in solib.c. */ 1725796c8dcSSimon Schubert struct symbol *solib_global_lookup (const struct objfile *objfile, 1735796c8dcSSimon Schubert const char *name, 1745796c8dcSSimon Schubert const domain_enum domain); 1755796c8dcSSimon Schubert 1765796c8dcSSimon Schubert #endif 177