]>
git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/sym-file-main.c
1 /* Copyright 2013 Free Software Foundation, Inc.
2 This program is free software; you can redistribute it and/or modify
3 it under the terms of the GNU General Public License as published by
4 the Free Software Foundation; either version 3 of the License, or
5 (at your option) any later version.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
12 You should have received a copy of the GNU General Public License
13 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #include "sym-file-loader.h"
22 gdb_add_symbol_file (void *addr
, const char *file
)
28 gdb_remove_symbol_file (void *addr
)
33 /* Load a shared library without relying on the standard
34 loader to test GDB's commands for adding and removing
35 symbol files at runtime. */
38 main (int argc
, const char *argv
[])
40 const char *file
= SHLIB_NAME
;
41 Elf_External_Ehdr
*ehdr
= NULL
;
42 struct segment
*head_seg
= NULL
;
43 Elf_External_Shdr
*text
;
44 char *text_addr
= NULL
;
45 int (*pbar
) () = NULL
;
46 int (*pfoo
) (int) = NULL
;
48 if (load_shlib (file
, &ehdr
, &head_seg
) != 0)
51 /* Get the text section. */
52 text
= find_shdr (ehdr
, ".text");
56 /* Notify GDB to add the symbol file. */
57 if (translate_offset (GET (text
, sh_offset
), head_seg
, (void **) &text_addr
)
61 gdb_add_symbol_file (text_addr
, file
);
63 /* Call bar from SHLIB_NAME. */
64 if (lookup_function ("bar", ehdr
, head_seg
, (void *) &pbar
) != 0)
69 /* Call foo from SHLIB_NAME. */
70 if (lookup_function ("foo", ehdr
, head_seg
, (void *) &pfoo
) != 0)
75 /* Notify GDB to remove the symbol file. */
76 gdb_remove_symbol_file (text_addr
);