• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

Revision8240bcfba31d7a7cafb172f41de57bdf4d4b1cee (tree)
Time2002-11-26 11:32:13
AuthorJim Blandy <jimb@code...>
CommiterJim Blandy

Log Message

* 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).

Change Summary

Incremental Difference

--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,15 @@
11 2002-11-25 Jim Blandy <jimb@redhat.com>
22
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+
313 * symfile.c (init_objfile_sect_indices): New function.
414 (default_symfile_offsets): Move the section-index-initializing
515 stuff into init_objfile_sect_indices, and call that.
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -2207,7 +2207,8 @@ symfile.o: symfile.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(gdbcore_h) \
22072207 $(frame_h) $(target_h) $(value_h) $(symfile_h) $(objfiles_h) \
22082208 $(gdbcmd_h) $(breakpoint_h) $(language_h) $(complaints_h) \
22092209 $(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)
22112212 symm-nat.o: symm-nat.c $(defs_h) $(frame_h) $(inferior_h) $(symtab_h) \
22122213 $(target_h) $(regcache_h) $(gdb_stat_h) $(gdbcore_h) $(gdbcore_h)
22132214 symm-tdep.o: symm-tdep.c $(defs_h) $(frame_h) $(inferior_h) $(symtab_h) \
--- a/gdb/rs6000-nat.c
+++ b/gdb/rs6000-nat.c
@@ -685,7 +685,7 @@ objfile_symbol_add (void *arg)
685685 {
686686 struct objfile *obj = (struct objfile *) arg;
687687
688- syms_from_objfile (obj, NULL, 0, 0);
688+ syms_from_objfile (obj, NULL, 0, 0, 0, 0);
689689 new_symfile_objfile (obj, 0, 0);
690690 return 1;
691691 }
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -42,6 +42,7 @@
4242 #include "gdb_obstack.h"
4343 #include "completer.h"
4444 #include "bcache.h"
45+#include "gdb_assert.h"
4546
4647 #include <sys/types.h>
4748 #include <fcntl.h>
@@ -571,8 +572,26 @@ default_symfile_offsets (struct objfile *objfile,
571572
572573 OBJFILE is where the symbols are to be read from.
573574
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.
576595
577596 MAINLINE is nonzero if this is the main symbol file, or zero if
578597 it's an extra symbol file such as dynamically loaded code.
@@ -581,8 +600,12 @@ default_symfile_offsets (struct objfile *objfile,
581600 the symbol reading (and complaints can be more terse about it). */
582601
583602 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)
586609 {
587610 asection *lower_sect;
588611 asection *sect;
@@ -591,16 +614,19 @@ syms_from_objfile (struct objfile *objfile, struct section_addr_info *addrs,
591614 struct cleanup *old_chain;
592615 int i;
593616
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));
597618
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)
599623 {
600624 memset (&local_addr, 0, sizeof (local_addr));
601625 addrs = &local_addr;
602626 }
603627
628+ /* Now either addrs or offsets is non-zero. */
629+
604630 init_entry_point_info (objfile);
605631 find_sym_fns (objfile);
606632
@@ -673,30 +699,32 @@ syms_from_objfile (struct objfile *objfile, struct section_addr_info *addrs,
673699 this_offset = lower_offset = lower_addr - lower_orig_addr */
674700
675701 /* 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+ }
700728 }
701729
702730 /* 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,
706734 (*objfile->sf->sym_init) (objfile);
707735 clear_complaints (&symfile_complaints, 1, verbo);
708736
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+ }
710752
711753 #ifndef IBM6000_TARGET
712754 /* 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,
887929 gdb_flush (gdb_stdout);
888930 }
889931 }
890- syms_from_objfile (objfile, addrs, mainline, from_tty);
932+ syms_from_objfile (objfile, addrs, 0, 0, mainline, from_tty);
891933 }
892934
893935 /* We now have at least a partial symbol table. Check to see if the
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -175,7 +175,10 @@ extern void add_symtab_fns (struct sym_fns *);
175175 extern void init_entry_point_info (struct objfile *);
176176
177177 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);
179182
180183 extern void new_symfile_objfile (struct objfile *, int, int);
181184