GNU Binutils with patches for OS216
Revision | 8240bcfba31d7a7cafb172f41de57bdf4d4b1cee (tree) |
---|---|
Time | 2002-11-26 11:32:13 |
Author | Jim Blandy <jimb@code...> |
Commiter | Jim Blandy |
* symfile.c: #include "gdb_assert.h".
(syms_from_objfile): Add the ability to pass in a section offset
table directly, as an alternative to the section_addr_info table.
Document arguments better.
(symbol_file_add): Pass extra arguments to syms_from_objfile.
* symfile.h (syms_from_objfile): Update declaration.
* rs6000-nat.c (objfile_symbol_add): Pass new arguments to
syms_from_objfile.
* Makefile.in (symfile.o): List dependency on $(gdb_assert_h).
@@ -1,5 +1,15 @@ | ||
1 | 1 | 2002-11-25 Jim Blandy <jimb@redhat.com> |
2 | 2 | |
3 | + * symfile.c: #include "gdb_assert.h". | |
4 | + (syms_from_objfile): Add the ability to pass in a section offset | |
5 | + table directly, as an alternative to the section_addr_info table. | |
6 | + Document arguments better. | |
7 | + (symbol_file_add): Pass extra arguments to syms_from_objfile. | |
8 | + * symfile.h (syms_from_objfile): Update declaration. | |
9 | + * rs6000-nat.c (objfile_symbol_add): Pass new arguments to | |
10 | + syms_from_objfile. | |
11 | + * Makefile.in (symfile.o): List dependency on $(gdb_assert_h). | |
12 | + | |
3 | 13 | * symfile.c (init_objfile_sect_indices): New function. |
4 | 14 | (default_symfile_offsets): Move the section-index-initializing |
5 | 15 | stuff into init_objfile_sect_indices, and call that. |
@@ -2207,7 +2207,8 @@ symfile.o: symfile.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(gdbcore_h) \ | ||
2207 | 2207 | $(frame_h) $(target_h) $(value_h) $(symfile_h) $(objfiles_h) \ |
2208 | 2208 | $(gdbcmd_h) $(breakpoint_h) $(language_h) $(complaints_h) \ |
2209 | 2209 | $(demangle_h) $(inferior_h) $(gdb_stabs_h) $(gdb_obstack_h) \ |
2210 | - $(completer_h) $(bcache_h) $(gdb_string_h) $(gdb_stat_h) $(source_h) | |
2210 | + $(completer_h) $(bcache_h) $(gdb_string_h) $(gdb_stat_h) $(source_h) \ | |
2211 | + $(gdb_assert_h) | |
2211 | 2212 | symm-nat.o: symm-nat.c $(defs_h) $(frame_h) $(inferior_h) $(symtab_h) \ |
2212 | 2213 | $(target_h) $(regcache_h) $(gdb_stat_h) $(gdbcore_h) $(gdbcore_h) |
2213 | 2214 | symm-tdep.o: symm-tdep.c $(defs_h) $(frame_h) $(inferior_h) $(symtab_h) \ |
@@ -685,7 +685,7 @@ objfile_symbol_add (void *arg) | ||
685 | 685 | { |
686 | 686 | struct objfile *obj = (struct objfile *) arg; |
687 | 687 | |
688 | - syms_from_objfile (obj, NULL, 0, 0); | |
688 | + syms_from_objfile (obj, NULL, 0, 0, 0, 0); | |
689 | 689 | new_symfile_objfile (obj, 0, 0); |
690 | 690 | return 1; |
691 | 691 | } |
@@ -42,6 +42,7 @@ | ||
42 | 42 | #include "gdb_obstack.h" |
43 | 43 | #include "completer.h" |
44 | 44 | #include "bcache.h" |
45 | +#include "gdb_assert.h" | |
45 | 46 | |
46 | 47 | #include <sys/types.h> |
47 | 48 | #include <fcntl.h> |
@@ -571,8 +572,26 @@ default_symfile_offsets (struct objfile *objfile, | ||
571 | 572 | |
572 | 573 | OBJFILE is where the symbols are to be read from. |
573 | 574 | |
574 | - ADDR is the address where the text segment was loaded, unless the | |
575 | - objfile is the main symbol file, in which case it is zero. | |
575 | + ADDRS is the list of section load addresses. If the user has given | |
576 | + an 'add-symbol-file' command, then this is the list of offsets and | |
577 | + addresses he or she provided as arguments to the command; or, if | |
578 | + we're handling a shared library, these are the actual addresses the | |
579 | + sections are loaded at, according to the inferior's dynamic linker | |
580 | + (as gleaned by GDB's shared library code). We convert each address | |
581 | + into an offset from the section VMA's as it appears in the object | |
582 | + file, and then call the file's sym_offsets function to convert this | |
583 | + into a format-specific offset table --- a `struct section_offsets'. | |
584 | + If ADDRS is non-zero, OFFSETS must be zero. | |
585 | + | |
586 | + OFFSETS is a table of section offsets already in the right | |
587 | + format-specific representation. NUM_OFFSETS is the number of | |
588 | + elements present in OFFSETS->offsets. If OFFSETS is non-zero, we | |
589 | + assume this is the proper table the call to sym_offsets described | |
590 | + above would produce. Instead of calling sym_offsets, we just dump | |
591 | + it right into objfile->section_offsets. (When we're re-reading | |
592 | + symbols from an objfile, we don't have the original load address | |
593 | + list any more; all we have is the section offset table.) If | |
594 | + OFFSETS is non-zero, ADDRS must be zero. | |
576 | 595 | |
577 | 596 | MAINLINE is nonzero if this is the main symbol file, or zero if |
578 | 597 | it's an extra symbol file such as dynamically loaded code. |
@@ -581,8 +600,12 @@ default_symfile_offsets (struct objfile *objfile, | ||
581 | 600 | the symbol reading (and complaints can be more terse about it). */ |
582 | 601 | |
583 | 602 | void |
584 | -syms_from_objfile (struct objfile *objfile, struct section_addr_info *addrs, | |
585 | - int mainline, int verbo) | |
603 | +syms_from_objfile (struct objfile *objfile, | |
604 | + struct section_addr_info *addrs, | |
605 | + struct section_offsets *offsets, | |
606 | + int num_offsets, | |
607 | + int mainline, | |
608 | + int verbo) | |
586 | 609 | { |
587 | 610 | asection *lower_sect; |
588 | 611 | asection *sect; |
@@ -591,16 +614,19 @@ syms_from_objfile (struct objfile *objfile, struct section_addr_info *addrs, | ||
591 | 614 | struct cleanup *old_chain; |
592 | 615 | int i; |
593 | 616 | |
594 | - /* If ADDRS is NULL, initialize the local section_addr_info struct and | |
595 | - point ADDRS to it. We now establish the convention that an addr of | |
596 | - zero means no load address was specified. */ | |
617 | + gdb_assert (! (addrs && offsets)); | |
597 | 618 | |
598 | - if (addrs == NULL) | |
619 | + /* If ADDRS and OFFSETS are both NULL, put together a dummy address | |
620 | + list. We now establish the convention that an addr of zero means | |
621 | + no load address was specified. */ | |
622 | + if (! addrs && ! offsets) | |
599 | 623 | { |
600 | 624 | memset (&local_addr, 0, sizeof (local_addr)); |
601 | 625 | addrs = &local_addr; |
602 | 626 | } |
603 | 627 | |
628 | + /* Now either addrs or offsets is non-zero. */ | |
629 | + | |
604 | 630 | init_entry_point_info (objfile); |
605 | 631 | find_sym_fns (objfile); |
606 | 632 |
@@ -673,30 +699,32 @@ syms_from_objfile (struct objfile *objfile, struct section_addr_info *addrs, | ||
673 | 699 | this_offset = lower_offset = lower_addr - lower_orig_addr */ |
674 | 700 | |
675 | 701 | /* Calculate offsets for sections. */ |
676 | - for (i=0 ; i < MAX_SECTIONS && addrs->other[i].name; i++) | |
677 | - { | |
678 | - if (addrs->other[i].addr != 0) | |
679 | - { | |
680 | - sect = bfd_get_section_by_name (objfile->obfd, | |
681 | - addrs->other[i].name); | |
682 | - if (sect) | |
683 | - { | |
684 | - addrs->other[i].addr | |
685 | - -= bfd_section_vma (objfile->obfd, sect); | |
686 | - lower_offset = addrs->other[i].addr; | |
687 | - /* This is the index used by BFD. */ | |
688 | - addrs->other[i].sectindex = sect->index ; | |
689 | - } | |
690 | - else | |
691 | - { | |
692 | - warning ("section %s not found in %s", addrs->other[i].name, | |
693 | - objfile->name); | |
694 | - addrs->other[i].addr = 0; | |
695 | - } | |
696 | - } | |
697 | - else | |
698 | - addrs->other[i].addr = lower_offset; | |
699 | - } | |
702 | + if (addrs) | |
703 | + for (i=0 ; i < MAX_SECTIONS && addrs->other[i].name; i++) | |
704 | + { | |
705 | + if (addrs->other[i].addr != 0) | |
706 | + { | |
707 | + sect = bfd_get_section_by_name (objfile->obfd, | |
708 | + addrs->other[i].name); | |
709 | + if (sect) | |
710 | + { | |
711 | + addrs->other[i].addr | |
712 | + -= bfd_section_vma (objfile->obfd, sect); | |
713 | + lower_offset = addrs->other[i].addr; | |
714 | + /* This is the index used by BFD. */ | |
715 | + addrs->other[i].sectindex = sect->index ; | |
716 | + } | |
717 | + else | |
718 | + { | |
719 | + warning ("section %s not found in %s", | |
720 | + addrs->other[i].name, | |
721 | + objfile->name); | |
722 | + addrs->other[i].addr = 0; | |
723 | + } | |
724 | + } | |
725 | + else | |
726 | + addrs->other[i].addr = lower_offset; | |
727 | + } | |
700 | 728 | } |
701 | 729 | |
702 | 730 | /* Initialize symbol reading routines for this objfile, allow complaints to |
@@ -706,7 +734,21 @@ syms_from_objfile (struct objfile *objfile, struct section_addr_info *addrs, | ||
706 | 734 | (*objfile->sf->sym_init) (objfile); |
707 | 735 | clear_complaints (&symfile_complaints, 1, verbo); |
708 | 736 | |
709 | - (*objfile->sf->sym_offsets) (objfile, addrs); | |
737 | + if (addrs) | |
738 | + (*objfile->sf->sym_offsets) (objfile, addrs); | |
739 | + else | |
740 | + { | |
741 | + size_t size = SIZEOF_N_SECTION_OFFSETS (num_offsets); | |
742 | + | |
743 | + /* Just copy in the offset table directly as given to us. */ | |
744 | + objfile->num_sections = num_offsets; | |
745 | + objfile->section_offsets | |
746 | + = ((struct section_offsets *) | |
747 | + obstack_alloc (&objfile->psymbol_obstack, size)); | |
748 | + memcpy (objfile->section_offsets, offsets, size); | |
749 | + | |
750 | + init_objfile_sect_indices (objfile); | |
751 | + } | |
710 | 752 | |
711 | 753 | #ifndef IBM6000_TARGET |
712 | 754 | /* This is a SVR4/SunOS specific hack, I think. In any event, it |
@@ -887,7 +929,7 @@ symbol_file_add (char *name, int from_tty, struct section_addr_info *addrs, | ||
887 | 929 | gdb_flush (gdb_stdout); |
888 | 930 | } |
889 | 931 | } |
890 | - syms_from_objfile (objfile, addrs, mainline, from_tty); | |
932 | + syms_from_objfile (objfile, addrs, 0, 0, mainline, from_tty); | |
891 | 933 | } |
892 | 934 | |
893 | 935 | /* We now have at least a partial symbol table. Check to see if the |
@@ -175,7 +175,10 @@ extern void add_symtab_fns (struct sym_fns *); | ||
175 | 175 | extern void init_entry_point_info (struct objfile *); |
176 | 176 | |
177 | 177 | extern void |
178 | -syms_from_objfile (struct objfile *, struct section_addr_info *, int, int); | |
178 | +syms_from_objfile (struct objfile *, | |
179 | + struct section_addr_info *, | |
180 | + struct section_offsets *, int, | |
181 | + int, int); | |
179 | 182 | |
180 | 183 | extern void new_symfile_objfile (struct objfile *, int, int); |
181 | 184 |