GNU gdb 5.2 Copyright 2002 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "hppa64-hp-hpux11.00"... Breakpoint 1 at 0x40000000000591b8: file ../../binutils-020617/bfd/elf.c, line 342. Breakpoint 1, bfd_elf_string_from_elf_section (abfd=0x80000000000514c8, shindex=4, strindex=6180) at ../../binutils-020617/bfd/elf.c:342 342 (*_bfd_error_handler) (gdb) bt #0 bfd_elf_string_from_elf_section (abfd=0x80000000000514c8, shindex=4, strindex=6180) at ../../binutils-020617/bfd/elf.c:342 #1 0x400000000004c384 in elf_link_add_object_symbols ( abfd=0x80000000000514c8, info=0x8000000000019450) at ../../binutils-020617/bfd/elflink.h:1720 #2 0x400000000004ab44 in L$0489 () at ../../binutils-020617/bfd/elflink.h:97 #3 0x40000000000181d8 in load_symbols (entry=0x800000000001eda8, place=0x800003ffff7f0c10) at ../../binutils-020617/ld/ldlang.c:1588 #4 0x40000000000191f0 in open_input_bfds (s=0x800000000001eda8, force=false) at ../../binutils-020617/ld/ldlang.c:1986 #5 0x400000000001d7ec in lang_process () at ../../binutils-020617/ld/ldlang.c:4202 #6 0x4000000000021730 in L$0067 () at ../../binutils-020617/ld/ldmain.c:404 #7 0xc00000000002a6d8 in $START$ () from /usr/lib/pa20_64/dld.sl #8 0x400000000004c384 in elf_link_add_object_symbols (abfd=0x1, info=0x40011a10) at ../../binutils-020617/bfd/elflink.h:1720 #9 0x2f646961672f636c in ?? () #10 0x400000000004c384 in elf_link_add_object_symbols ( abfd=0x4000000000001040, info=0x800003ffff7f0850) at ../../binutils-020617/bfd/elflink.h:1720 #11 0x810025aebfea38c in ?? () #12 0x400000000004c384 in elf_link_add_object_symbols (abfd=0x81c02580c2010d4, info=0x806025b0e7010d7) at ../../binutils-020617/bfd/elflink.h:1720 (gdb) frame 1 #1 0x400000000004c384 in elf_link_add_object_symbols ( abfd=0x80000000000514c8, info=0x8000000000019450) at ../../binutils-020617/bfd/elflink.h:1720 1720 name = bfd_elf_string_from_elf_section (abfd, hdr->sh_link, sym.st_name); (gdb) r print *abfd $1 = {filename = 0x800003ffff7f0160 "generate.sl", xvec = 0x800000000000b098, iostream = 0x800003ffff6d5a40, cacheable = true, target_defaulted = false, lru_prev = 0x800000000002b470, lru_next = 0x80000000000513a8, where = 1816, opened_once = false, mtime_set = false, mtime = 0, ifd = 0, format = bfd_object, direction = read_direction, flags = 336, origin = 0, output_has_begun = false, section_htab = {table = 0x8000000000088cb8, size = 4051, newfunc = 0x8000000000011838 <__DTOR_LIST__+14768>, memory = 0x80000000000516c8}, sections = 0x0, section_tail = 0x8000000000051550, section_count = 0, start_address = 4611686018427394120, symcount = 0, outsymbols = 0x0, arch_info = 0x800000000000c9c0, arelt_data = 0x0, my_archive = 0x0, next = 0x0, archive_head = 0x0, has_armap = false, link_next = 0x0, archive_pass = 0, tdata = {aout_data = 0x800000000006fa70, aout_ar_data = 0x800000000006fa70, oasys_obj_data = 0x800000000006fa70, oasys_ar_data = 0x800000000006fa70, coff_obj_data = 0x800000000006fa70, pe_obj_data = 0x800000000006fa70, xcoff_obj_data = 0x800000000006fa70, ecoff_obj_data = 0x800000000006fa70, ieee_data = 0x800000000006fa70, ieee_ar_data = 0x800000000006fa70, srec_data = 0x800000000006fa70, ihex_data = 0x800000000006fa70, tekhex_data = 0x800000000006fa70, elf_obj_data = 0x800000000006fa70, nlm_obj_data = 0x800000000006fa70, bout_data = 0x800000000006fa70, mmo_data = 0x800000000006fa70, sun_core_data = 0x800000000006fa70, sco5_core_data = 0x800000000006fa70, trad_core_data = 0x800000000006fa70, som_data = 0x800000000006fa70, hpux_core_data = 0x800000000006fa70, hppabsd_core_data = 0x800000000006fa70, sgi_core_data = 0x800000000006fa70, lynx_core_data = 0x800000000006fa70, osf_core_data = 0x800000000006fa70, cisco_core_data = 0x800000000006fa70, versados_data = 0x800000000006fa70, netbsd_core_data = 0x800000000006fa70, any = 0x800000000006fa70}, usrdata = 0x800000000001eda8, memory = 0x8000000000049618} (gdb) print sym.st_name (gdb) list 1715 else 1716 { 1717 /* Leave it up to the processor backend. */ 1718 } 1719 1720 name = bfd_elf_string_from_elf_section (abfd, hdr->sh_link, sym.st_name); 1721 if (name == (const char *) NULL) 1722 goto error_return; 1723 1724 if (sym.st_shndx == SHN_COMMON && ELF_ST_TYPE (sym.st_info) == STT_TLS) (gdb) 1725 { 1726 asection *tcomm = bfd_get_section_by_name (abfd, ".tcommon"); 1727 1728 if (tcomm == NULL) 1729 { 1730 tcomm = bfd_make_section (abfd, ".tcommon"); 1731 if (tcomm == NULL 1732 || !bfd_set_section_flags (abfd, tcomm, (SEC_ALLOC 1733 | SEC_IS_COMMON 1734 | SEC_LINKER_CREATED (gdb) print sym (gdb) frame 3 #3 0x40000000000181d8 in load_symbols (entry=0x800000000001eda8, place=0x800003ffff7f0c10) at ../../binutils-020617/ld/ldlang.c:1588 1588 if (bfd_link_add_symbols (entry->the_bfd, &link_info)) (gdb) frame 2 #2 0x400000000004ab44 in L$0489 () at ../../binutils-020617/bfd/elflink.h:97 97 return elf_link_add_archive_symbols (abfd, info); (gdb) list 92 switch (bfd_get_format (abfd)) 93 { 94 case bfd_object: 95 return elf_link_add_object_symbols (abfd, info); 96 case bfd_archive: 97 return elf_link_add_archive_symbols (abfd, info); 98 default: 99 bfd_set_error (bfd_error_wrong_format); 100 return false; 101 } (gdb) frame 1 #1 0x400000000004c384 in elf_link_add_object_symbols ( abfd=0x80000000000514c8, info=0x8000000000019450) at ../../binutils-020617/bfd/elflink.h:1720 1720 name = bfd_elf_string_from_elf_section (abfd, hdr->sh_link, sym.st_name); (gdb) list 1000 995 &size_change_ok, dt_needed)) 996 return false; 997 998 if (! override) 999 { 1000 if (! (_bfd_generic_link_add_one_symbol 1001 (info, abfd, shortname, BSF_INDIRECT, bfd_ind_section_ptr, 1002 (bfd_vma) 0, name, false, collect, 1003 (struct bfd_link_hash_entry **) &hi))) 1004 return false; (gdb) 1005 } 1006 else 1007 { 1008 /* In this case the symbol named SHORTNAME is overriding the 1009 indirect symbol we want to add. We were planning on making 1010 SHORTNAME an indirect symbol referring to NAME. SHORTNAME 1011 is the name without a version. NAME is the fully versioned 1012 name, and it is the default version. 1013 1014 Overriding means that we already saw a definition for the (gdb) 1015 symbol SHORTNAME in a regular object, and it is overriding 1016 the symbol defined in the dynamic object. 1017 1018 When this happens, we actually want to change NAME, the 1019 symbol we just added, to refer to SHORTNAME. This will cause 1020 references to NAME in the shared object to become references 1021 to SHORTNAME in the regular object. This is what we expect 1022 when we override a function in a shared object: that the 1023 references in the shared object will be mapped to the 1024 definition in the regular object. */ (gdb) 1025 1026 while (hi->root.type == bfd_link_hash_indirect 1027 || hi->root.type == bfd_link_hash_warning) 1028 hi = (struct elf_link_hash_entry *) hi->root.u.i.link; 1029 1030 h->root.type = bfd_link_hash_indirect; 1031 h->root.u.i.link = (struct bfd_link_hash_entry *) hi; 1032 if (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) 1033 { 1034 h->elf_link_hash_flags &=~ ELF_LINK_HASH_DEF_DYNAMIC; (gdb) 1035 hi->elf_link_hash_flags |= ELF_LINK_HASH_REF_DYNAMIC; 1036 if (hi->elf_link_hash_flags 1037 & (ELF_LINK_HASH_REF_REGULAR 1038 | ELF_LINK_HASH_DEF_REGULAR)) 1039 { 1040 if (! _bfd_elf_link_record_dynamic_symbol (info, hi)) 1041 return false; 1042 } 1043 } 1044 (gdb) 1045 /* Now set HI to H, so that the following code will set the 1046 other fields correctly. */ 1047 hi = h; 1048 } 1049 1050 /* If there is a duplicate definition somewhere, then HI may not 1051 point to an indirect symbol. We will have reported an error to 1052 the user in that case. */ 1053 1054 if (hi->root.type == bfd_link_hash_indirect) (gdb) 1055 { 1056 struct elf_link_hash_entry *ht; 1057 1058 /* If the symbol became indirect, then we assume that we have 1059 not seen a definition before. */ 1060 BFD_ASSERT ((hi->elf_link_hash_flags 1061 & (ELF_LINK_HASH_DEF_DYNAMIC 1062 | ELF_LINK_HASH_DEF_REGULAR)) == 0); 1063 1064 ht = (struct elf_link_hash_entry *) hi->root.u.i.link; (gdb) 1065 (*bed->elf_backend_copy_indirect_symbol) (ht, hi); 1066 1067 /* See if the new flags lead us to realize that the symbol must 1068 be dynamic. */ 1069 if (! *dynsym) 1070 { 1071 if (! dynamic) 1072 { 1073 if (info->shared 1074 || ((hi->elf_link_hash_flags (gdb) 1075 & ELF_LINK_HASH_REF_DYNAMIC) != 0)) 1076 *dynsym = true; 1077 } 1078 else 1079 { 1080 if ((hi->elf_link_hash_flags 1081 & ELF_LINK_HASH_REF_REGULAR) != 0) 1082 *dynsym = true; 1083 } 1084 } (gdb) 1085 } 1086 1087 /* We also need to define an indirection from the nondefault version 1088 of the symbol. */ 1089 1090 shortname = bfd_hash_allocate (&info->hash->table, strlen (name)); 1091 if (shortname == NULL) 1092 return false; 1093 strncpy (shortname, name, (size_t) (p - name)); 1094 strcpy (shortname + (p - name), p + 1); (gdb) 1095 1096 /* Once again, merge with any existing symbol. */ 1097 type_change_ok = false; 1098 size_change_ok = false; 1099 if (! elf_merge_symbol (abfd, info, shortname, sym, sec, value, 1100 &hi, &override, &type_change_ok, 1101 &size_change_ok, dt_needed)) 1102 return false; 1103 1104 if (override) (gdb) 1105 { 1106 /* Here SHORTNAME is a versioned name, so we don't expect to see 1107 the type of override we do in the case above. */ 1108 (*_bfd_error_handler) 1109 (_("%s: warning: unexpected redefinition of `%s'"), 1110 bfd_archive_filename (abfd), shortname); 1111 } 1112 else 1113 { 1114 if (! (_bfd_generic_link_add_one_symbol (gdb) 1115 (info, abfd, shortname, BSF_INDIRECT, 1116 bfd_ind_section_ptr, (bfd_vma) 0, name, false, 1117 collect, (struct bfd_link_hash_entry **) &hi))) 1118 return false; 1119 1120 /* If there is a duplicate definition somewhere, then HI may not 1121 point to an indirect symbol. We will have reported an error 1122 to the user in that case. */ 1123 1124 if (hi->root.type == bfd_link_hash_indirect) (gdb) 1125 { 1126 /* If the symbol became indirect, then we assume that we have 1127 not seen a definition before. */ 1128 BFD_ASSERT ((hi->elf_link_hash_flags 1129 & (ELF_LINK_HASH_DEF_DYNAMIC 1130 | ELF_LINK_HASH_DEF_REGULAR)) == 0); 1131 1132 (*bed->elf_backend_copy_indirect_symbol) (h, hi); 1133 1134 /* See if the new flags lead us to realize that the symbol (gdb) 1135 must be dynamic. */ 1136 if (! *dynsym) 1137 { 1138 if (! dynamic) 1139 { 1140 if (info->shared 1141 || ((hi->elf_link_hash_flags 1142 & ELF_LINK_HASH_REF_DYNAMIC) != 0)) 1143 *dynsym = true; 1144 } (gdb) 1145 else 1146 { 1147 if ((hi->elf_link_hash_flags 1148 & ELF_LINK_HASH_REF_REGULAR) != 0) 1149 *dynsym = true; 1150 } 1151 } 1152 } 1153 } 1154 (gdb) 1155 return true; 1156 } 1157 1158 /* Add symbols from an ELF object file to the linker hash table. */ 1159 1160 static boolean 1161 elf_link_add_object_symbols (abfd, info) 1162 bfd *abfd; 1163 struct bfd_link_info *info; 1164 { (gdb) 1165 boolean (*add_symbol_hook) PARAMS ((bfd *, struct bfd_link_info *, 1166 const Elf_Internal_Sym *, 1167 const char **, flagword *, 1168 asection **, bfd_vma *)); 1169 boolean (*check_relocs) PARAMS ((bfd *, struct bfd_link_info *, 1170 asection *, const Elf_Internal_Rela *)); 1171 boolean collect; 1172 Elf_Internal_Shdr *hdr; 1173 Elf_Internal_Shdr *shndx_hdr; 1174 bfd_size_type symcount; (gdb) 1175 bfd_size_type extsymcount; 1176 bfd_size_type extsymoff; 1177 Elf_External_Sym *buf = NULL; 1178 Elf_External_Sym_Shndx *shndx_buf = NULL; 1179 Elf_External_Sym_Shndx *shndx; 1180 struct elf_link_hash_entry **sym_hash; 1181 boolean dynamic; 1182 Elf_External_Versym *extversym = NULL; 1183 Elf_External_Versym *ever; 1184 Elf_External_Dyn *dynbuf = NULL; (gdb) 1185 struct elf_link_hash_entry *weaks; 1186 Elf_External_Sym *esym; 1187 Elf_External_Sym *esymend; 1188 struct elf_backend_data *bed; 1189 boolean dt_needed; 1190 struct elf_link_hash_table * hash_table; 1191 file_ptr pos; 1192 bfd_size_type amt; 1193 1194 hash_table = elf_hash_table (info); (gdb) prin     1195 1196 bed = get_elf_backend_data (abfd); 1197 add_symbol_hook = bed->elf_add_symbol_hook; 1198 collect = bed->collect; 1199 1200 if ((abfd->flags & DYNAMIC) == 0) 1201 dynamic = false; 1202 else 1203 { 1204 dynamic = true; (gdb) 1205 1206 /* You can't use -r against a dynamic object. Also, there's no 1207 hope of using a dynamic object which does not exactly match 1208 the format of the output file. */ 1209 if (info->relocateable || info->hash->creator != abfd->xvec) 1210 { 1211 bfd_set_error (bfd_error_invalid_operation); 1212 goto error_return; 1213 } 1214 } (gdb) 1215 1216 /* As a GNU extension, any input sections which are named 1217 .gnu.warning.SYMBOL are treated as warning symbols for the given 1218 symbol. This differs from .gnu.warning sections, which generate 1219 warnings when they are included in an output file. */ 1220 if (! info->shared) 1221 { 1222 asection *s; 1223 1224 for (s = abfd->sections; s != NULL; s = s->next) (gdb) 1225 { 1226 const char *name; 1227 1228 name = bfd_get_section_name (abfd, s); 1229 if (strncmp (name, ".gnu.warning.", sizeof ".gnu.warning." - 1) == 0) 1230 { 1231 char *msg; 1232 bfd_size_type sz; 1233 1234 name += sizeof ".gnu.warning." - 1; (gdb) 1235 1236 /* If this is a shared object, then look up the symbol 1237 in the hash table. If it is there, and it is already 1238 been defined, then we will not be using the entry 1239 from this shared object, so we don't need to warn. 1240 FIXME: If we see the definition in a regular object 1241 later on, we will warn, but we shouldn't. The only 1242 fix is to keep track of what warnings we are supposed 1243 to emit, and then handle them all at the end of the 1244 link. */ (gdb) 1245 if (dynamic && abfd->xvec == info->hash->creator) 1246 { 1247 struct elf_link_hash_entry *h; 1248 1249 h = elf_link_hash_lookup (hash_table, name, 1250 false, false, true); 1251 1252 /* FIXME: What about bfd_link_hash_common? */ 1253 if (h != NULL 1254 && (h->root.type == bfd_link_hash_defined (gdb) 1255 || h->root.type == bfd_link_hash_defweak)) 1256 { 1257 /* We don't want to issue this warning. Clobber 1258 the section size so that the warning does not 1259 get copied into the output file. */ 1260 s->_raw_size = 0; 1261 continue; 1262 } 1263 } 1264 (gdb) l bt #0 bfd_elf_string_from_elf_section (abfd=0x80000000000514c8, shindex=4, strindex=6180) at ../../binutils-020617/bfd/elf.c:342 #1 0x400000000004c384 in elf_link_add_object_symbols ( abfd=0x80000000000514c8, info=0x8000000000019450) at ../../binutils-020617/bfd/elflink.h:1720 #2 0x400000000004ab44 in L$0489 () at ../../binutils-020617/bfd/elflink.h:97 #3 0x40000000000181d8 in load_symbols (entry=0x800000000001eda8, place=0x800003ffff7f0c10) at ../../binutils-020617/ld/ldlang.c:1588 #4 0x40000000000191f0 in open_input_bfds (s=0x800000000001eda8, force=false) at ../../binutils-020617/ld/ldlang.c:1986 #5 0x400000000001d7ec in lang_process () at ../../binutils-020617/ld/ldlang.c:4202 #6 0x4000000000021730 in L$0067 () at ../../binutils-020617/ld/ldmain.c:404 #7 0xc00000000002a6d8 in $START$ () from /usr/lib/pa20_64/dld.sl #8 0x400000000004c384 in elf_link_add_object_symbols (abfd=0x1, info=0x40011a10) at ../../binutils-020617/bfd/elflink.h:1720 #9 0x2f646961672f636c in ?? () #10 0x400000000004c384 in elf_link_add_object_symbols ( abfd=0x4000000000001040, info=0x800003ffff7f0850) at ../../binutils-020617/bfd/elflink.h:1720 #11 0x810025aebfea38c in ?? () #12 0x400000000004c384 in elf_link_add_object_symbols (abfd=0x81c02580c2010d4, info=0x806025b0e7010d7) at ../../binutils-020617/bfd/elflink.h:1720 (gdb) frame 1 #1 0x400000000004c384 in elf_link_add_object_symbols ( abfd=0x80000000000514c8, info=0x8000000000019450) at ../../binutils-020617/bfd/elflink.h:1720 1720 name = bfd_elf_string_from_elf_section (abfd, hdr->sh_link, sym.st_name); (gdb) list 1700 1695 1696 if (sym.st_shndx == SHN_UNDEF) 1697 sec = bfd_und_section_ptr; 1698 else if (sym.st_shndx < SHN_LORESERVE || sym.st_shndx > SHN_HIRESERVE) 1699 { 1700 sec = section_from_elf_index (abfd, sym.st_shndx); 1701 if (sec == NULL) 1702 sec = bfd_abs_section_ptr; 1703 else if ((abfd->flags & (EXEC_P | DYNAMIC)) != 0) 1704 value -= sec->vma; (gdb) list 1600 1595 1596 dyncon = (Elf_External_Dyn *) sdyn->contents; 1597 dynconend = (Elf_External_Dyn *) (sdyn->contents + 1598 sdyn->_raw_size); 1599 for (; dyncon < dynconend; dyncon++) 1600 { 1601 Elf_Internal_Dyn dyn; 1602 1603 elf_swap_dyn_in (hash_table->dynobj, dyncon, & dyn); 1604 if (dyn.d_tag == DT_NEEDED (gdb) 1605 && dyn.d_un.d_val == strindex) 1606 { 1607 if (buf != NULL) 1608 free (buf); 1609 if (extversym != NULL) 1610 free (extversym); 1611 _bfd_elf_strtab_delref (hash_table->dynstr, strindex); 1612 return true; 1613 } 1614 } (gdb) 1615 } 1616 1617 if (! elf_add_dynamic_entry (info, (bfd_vma) DT_NEEDED, strindex)) 1618 goto error_return; 1619 } 1620 1621 /* Save the SONAME, if there is one, because sometimes the 1622 linker emulation code will need to know it. */ 1623 if (*name == '\0') 1624 name = basename (bfd_get_filename (abfd)); (gdb) 1625 elf_dt_name (abfd) = name; 1626 } 1627 1628 pos = hdr->sh_offset + extsymoff * sizeof (Elf_External_Sym); 1629 amt = extsymcount * sizeof (Elf_External_Sym); 1630 if (bfd_seek (abfd, pos, SEEK_SET) != 0 1631 || bfd_bread ((PTR) buf, amt, abfd) != amt) 1632 goto error_return; 1633 1634 if (shndx_hdr != NULL && shndx_hdr->sh_size != 0) (gdb) 1635 { 1636 amt = extsymcount * sizeof (Elf_External_Sym_Shndx); 1637 pos = shndx_hdr->sh_offset + extsymoff * sizeof (Elf_External_Sym_Shndx); 1638 if (bfd_seek (abfd, pos, SEEK_SET) != 0 1639 || bfd_bread ((PTR) shndx_buf, amt, abfd) != amt) 1640 goto error_return; 1641 } 1642 1643 weaks = NULL; 1644 (gdb) 1645 ever = extversym != NULL ? extversym + extsymoff : NULL; 1646 esymend = buf + extsymcount; 1647 for (esym = buf, shndx = shndx_buf; 1648 esym < esymend; 1649 esym++, sym_hash++, ever = (ever != NULL ? ever + 1 : NULL), 1650 shndx = (shndx != NULL ? shndx + 1 : NULL)) 1651 { 1652 Elf_Internal_Sym sym; 1653 int bind; 1654 bfd_vma value; (gdb) 1655 asection *sec; 1656 flagword flags; 1657 const char *name; 1658 struct elf_link_hash_entry *h; 1659 boolean definition; 1660 boolean size_change_ok, type_change_ok; 1661 boolean new_weakdef; 1662 unsigned int old_alignment; 1663 boolean override; 1664 (gdb) 1665 override = false; 1666 1667 elf_swap_symbol_in (abfd, (const PTR) esym, (const PTR) shndx, &sym); 1668 1669 flags = BSF_NO_FLAGS; 1670 sec = NULL; 1671 value = sym.st_value; 1672 *sym_hash = NULL; 1673 1674 bind = ELF_ST_BIND (sym.st_info); (gdb) print esym $2 = (struct {...} *) 0x8000000000051798 (gdb) print sym (gdb) print shxh  ndx $3 = (struct {...} *) 0x0 (gdb) print value (gdb) print value shndxym esym*esym $4 = {st_name = "\0\0\030$", st_info = "\022", st_other = "", st_shndx = "\0\r", st_value = "\200\0\0\001\0\0S\220", st_size = "\0\0\0\0\0\0\0\200"} (gdb) quit The program is running. Exit anyway? (y or n)