resolve.cc 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212
  1. // resolve.cc -- symbol resolution for gold
  2. // Copyright (C) 2006-2022 Free Software Foundation, Inc.
  3. // Written by Ian Lance Taylor <iant@google.com>.
  4. // This file is part of gold.
  5. // This program is free software; you can redistribute it and/or modify
  6. // it under the terms of the GNU General Public License as published by
  7. // the Free Software Foundation; either version 3 of the License, or
  8. // (at your option) any later version.
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. // You should have received a copy of the GNU General Public License
  14. // along with this program; if not, write to the Free Software
  15. // Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  16. // MA 02110-1301, USA.
  17. #include "gold.h"
  18. #include "elfcpp.h"
  19. #include "target.h"
  20. #include "object.h"
  21. #include "symtab.h"
  22. #include "plugin.h"
  23. namespace gold
  24. {
  25. // Symbol methods used in this file.
  26. // This symbol is being overridden by another symbol whose version is
  27. // VERSION. Update the VERSION_ field accordingly.
  28. inline void
  29. Symbol::override_version(const char* version)
  30. {
  31. if (version == NULL)
  32. {
  33. // This is the case where this symbol is NAME/VERSION, and the
  34. // version was not marked as hidden. That makes it the default
  35. // version, so we create NAME/NULL. Later we see another symbol
  36. // NAME/NULL, and that symbol is overriding this one. In this
  37. // case, since NAME/VERSION is the default, we make NAME/NULL
  38. // override NAME/VERSION as well. They are already the same
  39. // Symbol structure. Setting the VERSION_ field to NULL ensures
  40. // that it will be output with the correct, empty, version.
  41. this->version_ = version;
  42. }
  43. else
  44. {
  45. // This is the case where this symbol is NAME/VERSION_ONE, and
  46. // now we see NAME/VERSION_TWO, and NAME/VERSION_TWO is
  47. // overriding NAME. If VERSION_ONE and VERSION_TWO are
  48. // different, then this can only happen when VERSION_ONE is NULL
  49. // and VERSION_TWO is not hidden.
  50. gold_assert(this->version_ == version || this->version_ == NULL);
  51. this->version_ = version;
  52. }
  53. }
  54. // This symbol is being overidden by another symbol whose visibility
  55. // is VISIBILITY. Updated the VISIBILITY_ field accordingly.
  56. inline void
  57. Symbol::override_visibility(elfcpp::STV visibility)
  58. {
  59. // The rule for combining visibility is that we always choose the
  60. // most constrained visibility. In order of increasing constraint,
  61. // visibility goes PROTECTED, HIDDEN, INTERNAL. This is the reverse
  62. // of the numeric values, so the effect is that we always want the
  63. // smallest non-zero value.
  64. if (visibility != elfcpp::STV_DEFAULT)
  65. {
  66. if (this->visibility_ == elfcpp::STV_DEFAULT)
  67. this->visibility_ = visibility;
  68. else if (this->visibility_ > visibility)
  69. this->visibility_ = visibility;
  70. }
  71. }
  72. // Override the fields in Symbol.
  73. template<int size, bool big_endian>
  74. void
  75. Symbol::override_base(const elfcpp::Sym<size, big_endian>& sym,
  76. unsigned int st_shndx, bool is_ordinary,
  77. Object* object, const char* version)
  78. {
  79. gold_assert(this->source_ == FROM_OBJECT);
  80. this->u1_.object = object;
  81. this->override_version(version);
  82. this->u2_.shndx = st_shndx;
  83. this->is_ordinary_shndx_ = is_ordinary;
  84. // Don't override st_type from plugin placeholder symbols.
  85. if (object->pluginobj() == NULL)
  86. this->type_ = sym.get_st_type();
  87. this->binding_ = sym.get_st_bind();
  88. this->override_visibility(sym.get_st_visibility());
  89. this->nonvis_ = sym.get_st_nonvis();
  90. if (object->is_dynamic())
  91. this->in_dyn_ = true;
  92. else
  93. this->in_reg_ = true;
  94. }
  95. // Override the fields in Sized_symbol.
  96. template<int size>
  97. template<bool big_endian>
  98. void
  99. Sized_symbol<size>::override(const elfcpp::Sym<size, big_endian>& sym,
  100. unsigned st_shndx, bool is_ordinary,
  101. Object* object, const char* version)
  102. {
  103. this->override_base(sym, st_shndx, is_ordinary, object, version);
  104. this->value_ = sym.get_st_value();
  105. this->symsize_ = sym.get_st_size();
  106. }
  107. // Override TOSYM with symbol FROMSYM, defined in OBJECT, with version
  108. // VERSION. This handles all aliases of TOSYM.
  109. template<int size, bool big_endian>
  110. void
  111. Symbol_table::override(Sized_symbol<size>* tosym,
  112. const elfcpp::Sym<size, big_endian>& fromsym,
  113. unsigned int st_shndx, bool is_ordinary,
  114. Object* object, const char* version)
  115. {
  116. tosym->override(fromsym, st_shndx, is_ordinary, object, version);
  117. if (tosym->has_alias())
  118. {
  119. Symbol* sym = this->weak_aliases_[tosym];
  120. gold_assert(sym != NULL);
  121. Sized_symbol<size>* ssym = this->get_sized_symbol<size>(sym);
  122. do
  123. {
  124. ssym->override(fromsym, st_shndx, is_ordinary, object, version);
  125. sym = this->weak_aliases_[ssym];
  126. gold_assert(sym != NULL);
  127. ssym = this->get_sized_symbol<size>(sym);
  128. }
  129. while (ssym != tosym);
  130. }
  131. }
  132. // The resolve functions build a little code for each symbol.
  133. // Bit 0: 0 for global, 1 for weak.
  134. // Bit 1: 0 for regular object, 1 for shared object
  135. // Bits 2-3: 0 for normal, 1 for undefined, 2 for common
  136. // This gives us values from 0 to 11.
  137. static const int global_or_weak_shift = 0;
  138. static const unsigned int global_flag = 0 << global_or_weak_shift;
  139. static const unsigned int weak_flag = 1 << global_or_weak_shift;
  140. static const int regular_or_dynamic_shift = 1;
  141. static const unsigned int regular_flag = 0 << regular_or_dynamic_shift;
  142. static const unsigned int dynamic_flag = 1 << regular_or_dynamic_shift;
  143. static const int def_undef_or_common_shift = 2;
  144. static const unsigned int def_flag = 0 << def_undef_or_common_shift;
  145. static const unsigned int undef_flag = 1 << def_undef_or_common_shift;
  146. static const unsigned int common_flag = 2 << def_undef_or_common_shift;
  147. // This convenience function combines all the flags based on facts
  148. // about the symbol.
  149. static unsigned int
  150. symbol_to_bits(elfcpp::STB binding, bool is_dynamic,
  151. unsigned int shndx, bool is_ordinary)
  152. {
  153. unsigned int bits;
  154. switch (binding)
  155. {
  156. case elfcpp::STB_GLOBAL:
  157. case elfcpp::STB_GNU_UNIQUE:
  158. bits = global_flag;
  159. break;
  160. case elfcpp::STB_WEAK:
  161. bits = weak_flag;
  162. break;
  163. case elfcpp::STB_LOCAL:
  164. // We should only see externally visible symbols in the symbol
  165. // table.
  166. gold_error(_("invalid STB_LOCAL symbol in external symbols"));
  167. bits = global_flag;
  168. break;
  169. default:
  170. // Any target which wants to handle STB_LOOS, etc., needs to
  171. // define a resolve method.
  172. gold_error(_("unsupported symbol binding %d"), static_cast<int>(binding));
  173. bits = global_flag;
  174. }
  175. if (is_dynamic)
  176. bits |= dynamic_flag;
  177. else
  178. bits |= regular_flag;
  179. switch (shndx)
  180. {
  181. case elfcpp::SHN_UNDEF:
  182. bits |= undef_flag;
  183. break;
  184. case elfcpp::SHN_COMMON:
  185. if (!is_ordinary)
  186. bits |= common_flag;
  187. break;
  188. default:
  189. if (!is_ordinary && Symbol::is_common_shndx(shndx))
  190. bits |= common_flag;
  191. else
  192. bits |= def_flag;
  193. break;
  194. }
  195. return bits;
  196. }
  197. // Resolve a symbol. This is called the second and subsequent times
  198. // we see a symbol. TO is the pre-existing symbol. ST_SHNDX is the
  199. // section index for SYM, possibly adjusted for many sections.
  200. // IS_ORDINARY is whether ST_SHNDX is a normal section index rather
  201. // than a special code. ORIG_ST_SHNDX is the original section index,
  202. // before any munging because of discarded sections, except that all
  203. // non-ordinary section indexes are mapped to SHN_UNDEF. VERSION is
  204. // the version of SYM.
  205. template<int size, bool big_endian>
  206. void
  207. Symbol_table::resolve(Sized_symbol<size>* to,
  208. const elfcpp::Sym<size, big_endian>& sym,
  209. unsigned int st_shndx, bool is_ordinary,
  210. unsigned int orig_st_shndx,
  211. Object* object, const char* version,
  212. bool is_default_version)
  213. {
  214. bool to_is_ordinary;
  215. const unsigned int to_shndx = to->shndx(&to_is_ordinary);
  216. // It's possible for a symbol to be defined in an object file
  217. // using .symver to give it a version, and for there to also be
  218. // a linker script giving that symbol the same version. We
  219. // don't want to give a multiple-definition error for this
  220. // harmless redefinition.
  221. if (to->source() == Symbol::FROM_OBJECT
  222. && to->object() == object
  223. && to->is_defined()
  224. && is_ordinary
  225. && to_is_ordinary
  226. && to_shndx == st_shndx
  227. && to->value() == sym.get_st_value())
  228. return;
  229. // Likewise for an absolute symbol defined twice with the same value.
  230. if (!is_ordinary
  231. && st_shndx == elfcpp::SHN_ABS
  232. && !to_is_ordinary
  233. && to_shndx == elfcpp::SHN_ABS
  234. && to->value() == sym.get_st_value())
  235. return;
  236. if (parameters->target().has_resolve())
  237. {
  238. Sized_target<size, big_endian>* sized_target;
  239. sized_target = parameters->sized_target<size, big_endian>();
  240. if (sized_target->resolve(to, sym, object, version))
  241. return;
  242. }
  243. if (!object->is_dynamic())
  244. {
  245. if (sym.get_st_type() == elfcpp::STT_COMMON
  246. && (is_ordinary || !Symbol::is_common_shndx(st_shndx)))
  247. {
  248. gold_warning(_("STT_COMMON symbol '%s' in %s "
  249. "is not in a common section"),
  250. to->demangled_name().c_str(),
  251. to->object()->name().c_str());
  252. return;
  253. }
  254. // Record that we've seen this symbol in a regular object.
  255. to->set_in_reg();
  256. }
  257. else if (st_shndx == elfcpp::SHN_UNDEF
  258. && (to->visibility() == elfcpp::STV_HIDDEN
  259. || to->visibility() == elfcpp::STV_INTERNAL))
  260. {
  261. // The symbol is hidden, so a reference from a shared object
  262. // cannot bind to it. We tried issuing a warning in this case,
  263. // but that produces false positives when the symbol is
  264. // actually resolved in a different shared object (PR 15574).
  265. return;
  266. }
  267. else
  268. {
  269. // Record that we've seen this symbol in a dynamic object.
  270. to->set_in_dyn();
  271. }
  272. // Record if we've seen this symbol in a real ELF object (i.e., the
  273. // symbol is referenced from outside the world known to the plugin).
  274. if (object->pluginobj() == NULL && !object->is_dynamic())
  275. to->set_in_real_elf();
  276. // If we're processing replacement files, allow new symbols to override
  277. // the placeholders from the plugin objects.
  278. // Treat common symbols specially since it is possible that an ELF
  279. // file increased the size of the alignment.
  280. if (to->source() == Symbol::FROM_OBJECT)
  281. {
  282. Pluginobj* obj = to->object()->pluginobj();
  283. if (obj != NULL
  284. && parameters->options().plugins()->in_replacement_phase())
  285. {
  286. bool adjust_common = false;
  287. typename Sized_symbol<size>::Size_type tosize = 0;
  288. typename Sized_symbol<size>::Value_type tovalue = 0;
  289. if (to->is_common()
  290. && !is_ordinary && Symbol::is_common_shndx(st_shndx))
  291. {
  292. adjust_common = true;
  293. tosize = to->symsize();
  294. tovalue = to->value();
  295. }
  296. this->override(to, sym, st_shndx, is_ordinary, object, version);
  297. if (adjust_common)
  298. {
  299. if (tosize > to->symsize())
  300. to->set_symsize(tosize);
  301. if (tovalue > to->value())
  302. to->set_value(tovalue);
  303. }
  304. return;
  305. }
  306. }
  307. // A new weak undefined reference, merging with an old weak
  308. // reference, could be a One Definition Rule (ODR) violation --
  309. // especially if the types or sizes of the references differ. We'll
  310. // store such pairs and look them up later to make sure they
  311. // actually refer to the same lines of code. We also check
  312. // combinations of weak and strong, which might occur if one case is
  313. // inline and the other is not. (Note: not all ODR violations can
  314. // be found this way, and not everything this finds is an ODR
  315. // violation. But it's helpful to warn about.)
  316. if (parameters->options().detect_odr_violations()
  317. && (sym.get_st_bind() == elfcpp::STB_WEAK
  318. || to->binding() == elfcpp::STB_WEAK)
  319. && orig_st_shndx != elfcpp::SHN_UNDEF
  320. && to_is_ordinary
  321. && to_shndx != elfcpp::SHN_UNDEF
  322. && sym.get_st_size() != 0 // Ignore weird 0-sized symbols.
  323. && to->symsize() != 0
  324. && (sym.get_st_type() != to->type()
  325. || sym.get_st_size() != to->symsize())
  326. // C does not have a concept of ODR, so we only need to do this
  327. // on C++ symbols. These have (mangled) names starting with _Z.
  328. && to->name()[0] == '_' && to->name()[1] == 'Z')
  329. {
  330. Symbol_location fromloc
  331. = { object, orig_st_shndx, static_cast<off_t>(sym.get_st_value()) };
  332. Symbol_location toloc = { to->object(), to_shndx,
  333. static_cast<off_t>(to->value()) };
  334. this->candidate_odr_violations_[to->name()].insert(fromloc);
  335. this->candidate_odr_violations_[to->name()].insert(toloc);
  336. }
  337. // Plugins don't provide a symbol type, so adopt the existing type
  338. // if the FROM symbol is from a plugin.
  339. elfcpp::STT fromtype = (object->pluginobj() != NULL
  340. ? to->type()
  341. : sym.get_st_type());
  342. unsigned int frombits = symbol_to_bits(sym.get_st_bind(),
  343. object->is_dynamic(),
  344. st_shndx, is_ordinary);
  345. bool adjust_common_sizes;
  346. bool adjust_dyndef;
  347. typename Sized_symbol<size>::Size_type tosize = to->symsize();
  348. if (Symbol_table::should_override(to, frombits, fromtype, OBJECT,
  349. object, &adjust_common_sizes,
  350. &adjust_dyndef, is_default_version))
  351. {
  352. elfcpp::STB orig_tobinding = to->binding();
  353. typename Sized_symbol<size>::Value_type tovalue = to->value();
  354. this->override(to, sym, st_shndx, is_ordinary, object, version);
  355. if (adjust_common_sizes)
  356. {
  357. if (tosize > to->symsize())
  358. to->set_symsize(tosize);
  359. if (tovalue > to->value())
  360. to->set_value(tovalue);
  361. }
  362. if (adjust_dyndef)
  363. {
  364. // We are overriding an UNDEF or WEAK UNDEF with a DYN DEF.
  365. // Remember which kind of UNDEF it was for future reference.
  366. to->set_undef_binding(orig_tobinding);
  367. }
  368. }
  369. else
  370. {
  371. if (adjust_common_sizes)
  372. {
  373. if (sym.get_st_size() > tosize)
  374. to->set_symsize(sym.get_st_size());
  375. if (sym.get_st_value() > to->value())
  376. to->set_value(sym.get_st_value());
  377. }
  378. if (adjust_dyndef)
  379. {
  380. // We are keeping a DYN DEF after seeing an UNDEF or WEAK UNDEF.
  381. // Remember which kind of UNDEF it was.
  382. to->set_undef_binding(sym.get_st_bind());
  383. }
  384. // The ELF ABI says that even for a reference to a symbol we
  385. // merge the visibility.
  386. to->override_visibility(sym.get_st_visibility());
  387. }
  388. // If we have a non-WEAK reference from a regular object to a
  389. // dynamic object, mark the dynamic object as needed.
  390. if (to->is_from_dynobj() && to->in_reg() && !to->is_undef_binding_weak())
  391. to->object()->set_is_needed();
  392. if (adjust_common_sizes && parameters->options().warn_common())
  393. {
  394. if (tosize > sym.get_st_size())
  395. Symbol_table::report_resolve_problem(false,
  396. _("common of '%s' overriding "
  397. "smaller common"),
  398. to, OBJECT, object);
  399. else if (tosize < sym.get_st_size())
  400. Symbol_table::report_resolve_problem(false,
  401. _("common of '%s' overidden by "
  402. "larger common"),
  403. to, OBJECT, object);
  404. else
  405. Symbol_table::report_resolve_problem(false,
  406. _("multiple common of '%s'"),
  407. to, OBJECT, object);
  408. }
  409. }
  410. // Handle the core of symbol resolution. This is called with the
  411. // existing symbol, TO, and a bitflag describing the new symbol. This
  412. // returns true if we should override the existing symbol with the new
  413. // one, and returns false otherwise. It sets *ADJUST_COMMON_SIZES to
  414. // true if we should set the symbol size to the maximum of the TO and
  415. // FROM sizes. It handles error conditions.
  416. bool
  417. Symbol_table::should_override(const Symbol* to, unsigned int frombits,
  418. elfcpp::STT fromtype, Defined defined,
  419. Object* object, bool* adjust_common_sizes,
  420. bool* adjust_dyndef, bool is_default_version)
  421. {
  422. *adjust_common_sizes = false;
  423. *adjust_dyndef = false;
  424. unsigned int tobits;
  425. if (to->source() == Symbol::IS_UNDEFINED)
  426. tobits = symbol_to_bits(to->binding(), false, elfcpp::SHN_UNDEF, true);
  427. else if (to->source() != Symbol::FROM_OBJECT)
  428. tobits = symbol_to_bits(to->binding(), false, elfcpp::SHN_ABS, false);
  429. else
  430. {
  431. bool is_ordinary;
  432. unsigned int shndx = to->shndx(&is_ordinary);
  433. tobits = symbol_to_bits(to->binding(),
  434. to->object()->is_dynamic(),
  435. shndx,
  436. is_ordinary);
  437. }
  438. if ((to->type() == elfcpp::STT_TLS) ^ (fromtype == elfcpp::STT_TLS)
  439. && !to->is_placeholder())
  440. Symbol_table::report_resolve_problem(true,
  441. _("symbol '%s' used as both __thread "
  442. "and non-__thread"),
  443. to, defined, object);
  444. // We use a giant switch table for symbol resolution. This code is
  445. // unwieldy, but: 1) it is efficient; 2) we definitely handle all
  446. // cases; 3) it is easy to change the handling of a particular case.
  447. // The alternative would be a series of conditionals, but it is easy
  448. // to get the ordering wrong. This could also be done as a table,
  449. // but that is no easier to understand than this large switch
  450. // statement.
  451. // These are the values generated by the bit codes.
  452. enum
  453. {
  454. DEF = global_flag | regular_flag | def_flag,
  455. WEAK_DEF = weak_flag | regular_flag | def_flag,
  456. DYN_DEF = global_flag | dynamic_flag | def_flag,
  457. DYN_WEAK_DEF = weak_flag | dynamic_flag | def_flag,
  458. UNDEF = global_flag | regular_flag | undef_flag,
  459. WEAK_UNDEF = weak_flag | regular_flag | undef_flag,
  460. DYN_UNDEF = global_flag | dynamic_flag | undef_flag,
  461. DYN_WEAK_UNDEF = weak_flag | dynamic_flag | undef_flag,
  462. COMMON = global_flag | regular_flag | common_flag,
  463. WEAK_COMMON = weak_flag | regular_flag | common_flag,
  464. DYN_COMMON = global_flag | dynamic_flag | common_flag,
  465. DYN_WEAK_COMMON = weak_flag | dynamic_flag | common_flag
  466. };
  467. switch (tobits * 16 + frombits)
  468. {
  469. case DEF * 16 + DEF:
  470. // Two definitions of the same symbol.
  471. // If either symbol is defined by an object included using
  472. // --just-symbols, then don't warn. This is for compatibility
  473. // with the GNU linker. FIXME: This is a hack.
  474. if ((to->source() == Symbol::FROM_OBJECT && to->object()->just_symbols())
  475. || (object != NULL && object->just_symbols()))
  476. return false;
  477. if (!parameters->options().muldefs())
  478. Symbol_table::report_resolve_problem(true,
  479. _("multiple definition of '%s'"),
  480. to, defined, object);
  481. return false;
  482. case WEAK_DEF * 16 + DEF:
  483. // We've seen a weak definition, and now we see a strong
  484. // definition. In the original SVR4 linker, this was treated as
  485. // a multiple definition error. In the Solaris linker and the
  486. // GNU linker, a weak definition followed by a regular
  487. // definition causes the weak definition to be overridden. We
  488. // are currently compatible with the GNU linker. In the future
  489. // we should add a target specific option to change this.
  490. // FIXME.
  491. return true;
  492. case DYN_DEF * 16 + DEF:
  493. case DYN_WEAK_DEF * 16 + DEF:
  494. // We've seen a definition in a dynamic object, and now we see a
  495. // definition in a regular object. The definition in the
  496. // regular object overrides the definition in the dynamic
  497. // object.
  498. return true;
  499. case UNDEF * 16 + DEF:
  500. case WEAK_UNDEF * 16 + DEF:
  501. case DYN_UNDEF * 16 + DEF:
  502. case DYN_WEAK_UNDEF * 16 + DEF:
  503. // We've seen an undefined reference, and now we see a
  504. // definition. We use the definition.
  505. return true;
  506. case COMMON * 16 + DEF:
  507. case WEAK_COMMON * 16 + DEF:
  508. case DYN_COMMON * 16 + DEF:
  509. case DYN_WEAK_COMMON * 16 + DEF:
  510. // We've seen a common symbol and now we see a definition. The
  511. // definition overrides.
  512. if (parameters->options().warn_common())
  513. Symbol_table::report_resolve_problem(false,
  514. _("definition of '%s' overriding "
  515. "common"),
  516. to, defined, object);
  517. return true;
  518. case DEF * 16 + WEAK_DEF:
  519. case WEAK_DEF * 16 + WEAK_DEF:
  520. // We've seen a definition and now we see a weak definition. We
  521. // ignore the new weak definition.
  522. return false;
  523. case DYN_DEF * 16 + WEAK_DEF:
  524. case DYN_WEAK_DEF * 16 + WEAK_DEF:
  525. // We've seen a dynamic definition and now we see a regular weak
  526. // definition. The regular weak definition overrides.
  527. return true;
  528. case UNDEF * 16 + WEAK_DEF:
  529. case WEAK_UNDEF * 16 + WEAK_DEF:
  530. case DYN_UNDEF * 16 + WEAK_DEF:
  531. case DYN_WEAK_UNDEF * 16 + WEAK_DEF:
  532. // A weak definition of a currently undefined symbol.
  533. return true;
  534. case COMMON * 16 + WEAK_DEF:
  535. case WEAK_COMMON * 16 + WEAK_DEF:
  536. // A weak definition does not override a common definition.
  537. return false;
  538. case DYN_COMMON * 16 + WEAK_DEF:
  539. case DYN_WEAK_COMMON * 16 + WEAK_DEF:
  540. // A weak definition does override a definition in a dynamic
  541. // object.
  542. if (parameters->options().warn_common())
  543. Symbol_table::report_resolve_problem(false,
  544. _("definition of '%s' overriding "
  545. "dynamic common definition"),
  546. to, defined, object);
  547. return true;
  548. case DEF * 16 + DYN_DEF:
  549. case WEAK_DEF * 16 + DYN_DEF:
  550. // Ignore a dynamic definition if we already have a definition.
  551. return false;
  552. case DYN_DEF * 16 + DYN_DEF:
  553. case DYN_WEAK_DEF * 16 + DYN_DEF:
  554. // Ignore a dynamic definition if we already have a definition,
  555. // unless the existing definition is an unversioned definition
  556. // in the same dynamic object, and the new definition is a
  557. // default version.
  558. if (to->object() == object
  559. && to->version() == NULL
  560. && is_default_version)
  561. return true;
  562. // Or, if the existing definition is in an unused --as-needed library,
  563. // and the reference is weak, let the new definition override.
  564. if (to->in_reg()
  565. && to->is_undef_binding_weak()
  566. && to->object()->as_needed()
  567. && !to->object()->is_needed())
  568. return true;
  569. return false;
  570. case UNDEF * 16 + DYN_DEF:
  571. case DYN_UNDEF * 16 + DYN_DEF:
  572. case DYN_WEAK_UNDEF * 16 + DYN_DEF:
  573. // Use a dynamic definition if we have a reference.
  574. return true;
  575. case WEAK_UNDEF * 16 + DYN_DEF:
  576. // When overriding a weak undef by a dynamic definition,
  577. // we need to remember that the original undef was weak.
  578. *adjust_dyndef = true;
  579. return true;
  580. case COMMON * 16 + DYN_DEF:
  581. case WEAK_COMMON * 16 + DYN_DEF:
  582. // Ignore a dynamic definition if we already have a common
  583. // definition.
  584. return false;
  585. case DEF * 16 + DYN_WEAK_DEF:
  586. case WEAK_DEF * 16 + DYN_WEAK_DEF:
  587. // Ignore a weak dynamic definition if we already have a
  588. // definition.
  589. return false;
  590. case UNDEF * 16 + DYN_WEAK_DEF:
  591. // When overriding an undef by a dynamic weak definition,
  592. // we need to remember that the original undef was not weak.
  593. *adjust_dyndef = true;
  594. return true;
  595. case DYN_UNDEF * 16 + DYN_WEAK_DEF:
  596. case DYN_WEAK_UNDEF * 16 + DYN_WEAK_DEF:
  597. // Use a weak dynamic definition if we have a reference.
  598. return true;
  599. case WEAK_UNDEF * 16 + DYN_WEAK_DEF:
  600. // When overriding a weak undef by a dynamic definition,
  601. // we need to remember that the original undef was weak.
  602. *adjust_dyndef = true;
  603. return true;
  604. case COMMON * 16 + DYN_WEAK_DEF:
  605. case WEAK_COMMON * 16 + DYN_WEAK_DEF:
  606. // Ignore a weak dynamic definition if we already have a common
  607. // definition.
  608. return false;
  609. case DYN_COMMON * 16 + DYN_DEF:
  610. case DYN_WEAK_COMMON * 16 + DYN_DEF:
  611. case DYN_DEF * 16 + DYN_WEAK_DEF:
  612. case DYN_WEAK_DEF * 16 + DYN_WEAK_DEF:
  613. case DYN_COMMON * 16 + DYN_WEAK_DEF:
  614. case DYN_WEAK_COMMON * 16 + DYN_WEAK_DEF:
  615. // If the existing definition is in an unused --as-needed library,
  616. // and the reference is weak, let a new dynamic definition override.
  617. if (to->in_reg()
  618. && to->is_undef_binding_weak()
  619. && to->object()->as_needed()
  620. && !to->object()->is_needed())
  621. return true;
  622. return false;
  623. case DEF * 16 + UNDEF:
  624. case WEAK_DEF * 16 + UNDEF:
  625. case UNDEF * 16 + UNDEF:
  626. // A new undefined reference tells us nothing.
  627. return false;
  628. case DYN_DEF * 16 + UNDEF:
  629. case DYN_WEAK_DEF * 16 + UNDEF:
  630. // For a dynamic def, we need to remember which kind of undef we see.
  631. *adjust_dyndef = true;
  632. return false;
  633. case WEAK_UNDEF * 16 + UNDEF:
  634. case DYN_UNDEF * 16 + UNDEF:
  635. case DYN_WEAK_UNDEF * 16 + UNDEF:
  636. // A strong undef overrides a dynamic or weak undef.
  637. return true;
  638. case COMMON * 16 + UNDEF:
  639. case WEAK_COMMON * 16 + UNDEF:
  640. case DYN_COMMON * 16 + UNDEF:
  641. case DYN_WEAK_COMMON * 16 + UNDEF:
  642. // A new undefined reference tells us nothing.
  643. return false;
  644. case DEF * 16 + WEAK_UNDEF:
  645. case WEAK_DEF * 16 + WEAK_UNDEF:
  646. case UNDEF * 16 + WEAK_UNDEF:
  647. case WEAK_UNDEF * 16 + WEAK_UNDEF:
  648. case DYN_UNDEF * 16 + WEAK_UNDEF:
  649. case COMMON * 16 + WEAK_UNDEF:
  650. case WEAK_COMMON * 16 + WEAK_UNDEF:
  651. case DYN_COMMON * 16 + WEAK_UNDEF:
  652. case DYN_WEAK_COMMON * 16 + WEAK_UNDEF:
  653. // A new weak undefined reference tells us nothing unless the
  654. // exisiting symbol is a dynamic weak reference.
  655. return false;
  656. case DYN_WEAK_UNDEF * 16 + WEAK_UNDEF:
  657. // A new weak reference overrides an existing dynamic weak reference.
  658. // This is necessary because a dynamic weak reference remembers
  659. // the old binding, which may not be weak. If we keeps the existing
  660. // dynamic weak reference, the weakness may be dropped in the output.
  661. return true;
  662. case DYN_DEF * 16 + WEAK_UNDEF:
  663. case DYN_WEAK_DEF * 16 + WEAK_UNDEF:
  664. // For a dynamic def, we need to remember which kind of undef we see.
  665. *adjust_dyndef = true;
  666. return false;
  667. case DEF * 16 + DYN_UNDEF:
  668. case WEAK_DEF * 16 + DYN_UNDEF:
  669. case DYN_DEF * 16 + DYN_UNDEF:
  670. case DYN_WEAK_DEF * 16 + DYN_UNDEF:
  671. case UNDEF * 16 + DYN_UNDEF:
  672. case WEAK_UNDEF * 16 + DYN_UNDEF:
  673. case DYN_UNDEF * 16 + DYN_UNDEF:
  674. case DYN_WEAK_UNDEF * 16 + DYN_UNDEF:
  675. case COMMON * 16 + DYN_UNDEF:
  676. case WEAK_COMMON * 16 + DYN_UNDEF:
  677. case DYN_COMMON * 16 + DYN_UNDEF:
  678. case DYN_WEAK_COMMON * 16 + DYN_UNDEF:
  679. // A new dynamic undefined reference tells us nothing.
  680. return false;
  681. case DEF * 16 + DYN_WEAK_UNDEF:
  682. case WEAK_DEF * 16 + DYN_WEAK_UNDEF:
  683. case DYN_DEF * 16 + DYN_WEAK_UNDEF:
  684. case DYN_WEAK_DEF * 16 + DYN_WEAK_UNDEF:
  685. case UNDEF * 16 + DYN_WEAK_UNDEF:
  686. case WEAK_UNDEF * 16 + DYN_WEAK_UNDEF:
  687. case DYN_UNDEF * 16 + DYN_WEAK_UNDEF:
  688. case DYN_WEAK_UNDEF * 16 + DYN_WEAK_UNDEF:
  689. case COMMON * 16 + DYN_WEAK_UNDEF:
  690. case WEAK_COMMON * 16 + DYN_WEAK_UNDEF:
  691. case DYN_COMMON * 16 + DYN_WEAK_UNDEF:
  692. case DYN_WEAK_COMMON * 16 + DYN_WEAK_UNDEF:
  693. // A new weak dynamic undefined reference tells us nothing.
  694. return false;
  695. case DEF * 16 + COMMON:
  696. // A common symbol does not override a definition.
  697. if (parameters->options().warn_common())
  698. Symbol_table::report_resolve_problem(false,
  699. _("common '%s' overridden by "
  700. "previous definition"),
  701. to, defined, object);
  702. return false;
  703. case WEAK_DEF * 16 + COMMON:
  704. case DYN_DEF * 16 + COMMON:
  705. case DYN_WEAK_DEF * 16 + COMMON:
  706. // A common symbol does override a weak definition or a dynamic
  707. // definition.
  708. return true;
  709. case UNDEF * 16 + COMMON:
  710. case WEAK_UNDEF * 16 + COMMON:
  711. case DYN_UNDEF * 16 + COMMON:
  712. case DYN_WEAK_UNDEF * 16 + COMMON:
  713. // A common symbol is a definition for a reference.
  714. return true;
  715. case COMMON * 16 + COMMON:
  716. // Set the size to the maximum.
  717. *adjust_common_sizes = true;
  718. return false;
  719. case WEAK_COMMON * 16 + COMMON:
  720. // I'm not sure just what a weak common symbol means, but
  721. // presumably it can be overridden by a regular common symbol.
  722. return true;
  723. case DYN_COMMON * 16 + COMMON:
  724. case DYN_WEAK_COMMON * 16 + COMMON:
  725. // Use the real common symbol, but adjust the size if necessary.
  726. *adjust_common_sizes = true;
  727. return true;
  728. case DEF * 16 + WEAK_COMMON:
  729. case WEAK_DEF * 16 + WEAK_COMMON:
  730. case DYN_DEF * 16 + WEAK_COMMON:
  731. case DYN_WEAK_DEF * 16 + WEAK_COMMON:
  732. // Whatever a weak common symbol is, it won't override a
  733. // definition.
  734. return false;
  735. case UNDEF * 16 + WEAK_COMMON:
  736. case WEAK_UNDEF * 16 + WEAK_COMMON:
  737. case DYN_UNDEF * 16 + WEAK_COMMON:
  738. case DYN_WEAK_UNDEF * 16 + WEAK_COMMON:
  739. // A weak common symbol is better than an undefined symbol.
  740. return true;
  741. case COMMON * 16 + WEAK_COMMON:
  742. case WEAK_COMMON * 16 + WEAK_COMMON:
  743. case DYN_COMMON * 16 + WEAK_COMMON:
  744. case DYN_WEAK_COMMON * 16 + WEAK_COMMON:
  745. // Ignore a weak common symbol in the presence of a real common
  746. // symbol.
  747. return false;
  748. case DEF * 16 + DYN_COMMON:
  749. case WEAK_DEF * 16 + DYN_COMMON:
  750. case DYN_DEF * 16 + DYN_COMMON:
  751. case DYN_WEAK_DEF * 16 + DYN_COMMON:
  752. // Ignore a dynamic common symbol in the presence of a
  753. // definition.
  754. return false;
  755. case UNDEF * 16 + DYN_COMMON:
  756. case WEAK_UNDEF * 16 + DYN_COMMON:
  757. case DYN_UNDEF * 16 + DYN_COMMON:
  758. case DYN_WEAK_UNDEF * 16 + DYN_COMMON:
  759. // A dynamic common symbol is a definition of sorts.
  760. return true;
  761. case COMMON * 16 + DYN_COMMON:
  762. case WEAK_COMMON * 16 + DYN_COMMON:
  763. case DYN_COMMON * 16 + DYN_COMMON:
  764. case DYN_WEAK_COMMON * 16 + DYN_COMMON:
  765. // Set the size to the maximum.
  766. *adjust_common_sizes = true;
  767. return false;
  768. case DEF * 16 + DYN_WEAK_COMMON:
  769. case WEAK_DEF * 16 + DYN_WEAK_COMMON:
  770. case DYN_DEF * 16 + DYN_WEAK_COMMON:
  771. case DYN_WEAK_DEF * 16 + DYN_WEAK_COMMON:
  772. // A common symbol is ignored in the face of a definition.
  773. return false;
  774. case UNDEF * 16 + DYN_WEAK_COMMON:
  775. case WEAK_UNDEF * 16 + DYN_WEAK_COMMON:
  776. case DYN_UNDEF * 16 + DYN_WEAK_COMMON:
  777. case DYN_WEAK_UNDEF * 16 + DYN_WEAK_COMMON:
  778. // I guess a weak common symbol is better than a definition.
  779. return true;
  780. case COMMON * 16 + DYN_WEAK_COMMON:
  781. case WEAK_COMMON * 16 + DYN_WEAK_COMMON:
  782. case DYN_COMMON * 16 + DYN_WEAK_COMMON:
  783. case DYN_WEAK_COMMON * 16 + DYN_WEAK_COMMON:
  784. // Set the size to the maximum.
  785. *adjust_common_sizes = true;
  786. return false;
  787. default:
  788. gold_unreachable();
  789. }
  790. }
  791. // Issue an error or warning due to symbol resolution. IS_ERROR
  792. // indicates an error rather than a warning. MSG is the error
  793. // message; it is expected to have a %s for the symbol name. TO is
  794. // the existing symbol. DEFINED/OBJECT is where the new symbol was
  795. // found.
  796. // FIXME: We should have better location information here. When the
  797. // symbol is defined, we should be able to pull the location from the
  798. // debug info if there is any.
  799. void
  800. Symbol_table::report_resolve_problem(bool is_error, const char* msg,
  801. const Symbol* to, Defined defined,
  802. Object* object)
  803. {
  804. std::string demangled(to->demangled_name());
  805. size_t len = strlen(msg) + demangled.length() + 10;
  806. char* buf = new char[len];
  807. snprintf(buf, len, msg, demangled.c_str());
  808. const char* objname;
  809. switch (defined)
  810. {
  811. case OBJECT:
  812. objname = object->name().c_str();
  813. break;
  814. case COPY:
  815. objname = _("COPY reloc");
  816. break;
  817. case DEFSYM:
  818. case UNDEFINED:
  819. objname = _("command line");
  820. break;
  821. case SCRIPT:
  822. objname = _("linker script");
  823. break;
  824. case PREDEFINED:
  825. case INCREMENTAL_BASE:
  826. objname = _("linker defined");
  827. break;
  828. default:
  829. gold_unreachable();
  830. }
  831. if (is_error)
  832. gold_error("%s: %s", objname, buf);
  833. else
  834. gold_warning("%s: %s", objname, buf);
  835. delete[] buf;
  836. if (to->source() == Symbol::FROM_OBJECT)
  837. objname = to->object()->name().c_str();
  838. else
  839. objname = _("command line");
  840. gold_info("%s: %s: previous definition here", program_name, objname);
  841. }
  842. // Completely override existing symbol. Everything bar name_,
  843. // version_, and is_forced_local_ flag are copied. version_ is
  844. // cleared if from->version_ is clear. Returns true if this symbol
  845. // should be forced local.
  846. bool
  847. Symbol::clone(const Symbol* from)
  848. {
  849. // Don't allow cloning after dynamic linking info is attached to symbols.
  850. // We aren't prepared to merge such.
  851. gold_assert(!this->has_symtab_index() && !from->has_symtab_index());
  852. gold_assert(!this->has_dynsym_index() && !from->has_dynsym_index());
  853. gold_assert(this->got_offset_list() == NULL
  854. && from->got_offset_list() == NULL);
  855. gold_assert(!this->has_plt_offset() && !from->has_plt_offset());
  856. if (!from->version_)
  857. this->version_ = from->version_;
  858. this->u1_ = from->u1_;
  859. this->u2_ = from->u2_;
  860. this->type_ = from->type_;
  861. this->binding_ = from->binding_;
  862. this->visibility_ = from->visibility_;
  863. this->nonvis_ = from->nonvis_;
  864. this->source_ = from->source_;
  865. this->is_def_ = from->is_def_;
  866. this->is_forwarder_ = from->is_forwarder_;
  867. this->has_alias_ = from->has_alias_;
  868. this->needs_dynsym_entry_ = from->needs_dynsym_entry_;
  869. this->in_reg_ = from->in_reg_;
  870. this->in_dyn_ = from->in_dyn_;
  871. this->needs_dynsym_value_ = from->needs_dynsym_value_;
  872. this->has_warning_ = from->has_warning_;
  873. this->is_copied_from_dynobj_ = from->is_copied_from_dynobj_;
  874. this->is_ordinary_shndx_ = from->is_ordinary_shndx_;
  875. this->in_real_elf_ = from->in_real_elf_;
  876. this->is_defined_in_discarded_section_
  877. = from->is_defined_in_discarded_section_;
  878. this->undef_binding_set_ = from->undef_binding_set_;
  879. this->undef_binding_weak_ = from->undef_binding_weak_;
  880. this->is_predefined_ = from->is_predefined_;
  881. this->is_protected_ = from->is_protected_;
  882. this->non_zero_localentry_ = from->non_zero_localentry_;
  883. return !this->is_forced_local_ && from->is_forced_local_;
  884. }
  885. template <int size>
  886. bool
  887. Sized_symbol<size>::clone(const Sized_symbol<size>* from)
  888. {
  889. this->value_ = from->value_;
  890. this->symsize_ = from->symsize_;
  891. return Symbol::clone(from);
  892. }
  893. // A special case of should_override which is only called for a strong
  894. // defined symbol from a regular object file. This is used when
  895. // defining special symbols.
  896. bool
  897. Symbol_table::should_override_with_special(const Symbol* to,
  898. elfcpp::STT fromtype,
  899. Defined defined)
  900. {
  901. bool adjust_common_sizes;
  902. bool adjust_dyn_def;
  903. unsigned int frombits = global_flag | regular_flag | def_flag;
  904. bool ret = Symbol_table::should_override(to, frombits, fromtype, defined,
  905. NULL, &adjust_common_sizes,
  906. &adjust_dyn_def, false);
  907. gold_assert(!adjust_common_sizes && !adjust_dyn_def);
  908. return ret;
  909. }
  910. // Override symbol base with a special symbol.
  911. void
  912. Symbol::override_base_with_special(const Symbol* from)
  913. {
  914. bool same_name = this->name_ == from->name_;
  915. gold_assert(same_name || this->has_alias());
  916. // If we are overriding an undef, remember the original binding.
  917. if (this->is_undefined())
  918. this->set_undef_binding(this->binding_);
  919. this->source_ = from->source_;
  920. switch (from->source_)
  921. {
  922. case FROM_OBJECT:
  923. case IN_OUTPUT_DATA:
  924. case IN_OUTPUT_SEGMENT:
  925. this->u1_ = from->u1_;
  926. this->u2_ = from->u2_;
  927. break;
  928. case IS_CONSTANT:
  929. case IS_UNDEFINED:
  930. break;
  931. default:
  932. gold_unreachable();
  933. break;
  934. }
  935. if (same_name)
  936. {
  937. // When overriding a versioned symbol with a special symbol, we
  938. // may be changing the version. This will happen if we see a
  939. // special symbol such as "_end" defined in a shared object with
  940. // one version (from a version script), but we want to define it
  941. // here with a different version (from a different version
  942. // script).
  943. this->version_ = from->version_;
  944. }
  945. this->type_ = from->type_;
  946. this->binding_ = from->binding_;
  947. this->override_visibility(from->visibility_);
  948. this->nonvis_ = from->nonvis_;
  949. // Special symbols are always considered to be regular symbols.
  950. this->in_reg_ = true;
  951. if (from->needs_dynsym_entry_)
  952. this->needs_dynsym_entry_ = true;
  953. if (from->needs_dynsym_value_)
  954. this->needs_dynsym_value_ = true;
  955. this->is_predefined_ = from->is_predefined_;
  956. // We shouldn't see these flags. If we do, we need to handle them
  957. // somehow.
  958. gold_assert(!from->is_forwarder_);
  959. gold_assert(!from->has_plt_offset());
  960. gold_assert(!from->has_warning_);
  961. gold_assert(!from->is_copied_from_dynobj_);
  962. gold_assert(!from->is_forced_local_);
  963. }
  964. // Override a symbol with a special symbol.
  965. template<int size>
  966. void
  967. Sized_symbol<size>::override_with_special(const Sized_symbol<size>* from)
  968. {
  969. this->override_base_with_special(from);
  970. this->value_ = from->value_;
  971. this->symsize_ = from->symsize_;
  972. }
  973. // Override TOSYM with the special symbol FROMSYM. This handles all
  974. // aliases of TOSYM.
  975. template<int size>
  976. void
  977. Symbol_table::override_with_special(Sized_symbol<size>* tosym,
  978. const Sized_symbol<size>* fromsym)
  979. {
  980. tosym->override_with_special(fromsym);
  981. if (tosym->has_alias())
  982. {
  983. Symbol* sym = this->weak_aliases_[tosym];
  984. gold_assert(sym != NULL);
  985. Sized_symbol<size>* ssym = this->get_sized_symbol<size>(sym);
  986. do
  987. {
  988. ssym->override_with_special(fromsym);
  989. sym = this->weak_aliases_[ssym];
  990. gold_assert(sym != NULL);
  991. ssym = this->get_sized_symbol<size>(sym);
  992. }
  993. while (ssym != tosym);
  994. }
  995. if (tosym->binding() == elfcpp::STB_LOCAL
  996. || ((tosym->visibility() == elfcpp::STV_HIDDEN
  997. || tosym->visibility() == elfcpp::STV_INTERNAL)
  998. && (tosym->binding() == elfcpp::STB_GLOBAL
  999. || tosym->binding() == elfcpp::STB_GNU_UNIQUE
  1000. || tosym->binding() == elfcpp::STB_WEAK)
  1001. && !parameters->options().relocatable()))
  1002. this->force_local(tosym);
  1003. }
  1004. // Instantiate the templates we need. We could use the configure
  1005. // script to restrict this to only the ones needed for implemented
  1006. // targets.
  1007. // We have to instantiate both big and little endian versions because
  1008. // these are used by other templates that depends on size only.
  1009. #if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_32_BIG)
  1010. template
  1011. void
  1012. Symbol_table::resolve<32, false>(
  1013. Sized_symbol<32>* to,
  1014. const elfcpp::Sym<32, false>& sym,
  1015. unsigned int st_shndx,
  1016. bool is_ordinary,
  1017. unsigned int orig_st_shndx,
  1018. Object* object,
  1019. const char* version,
  1020. bool is_default_version);
  1021. template
  1022. void
  1023. Symbol_table::resolve<32, true>(
  1024. Sized_symbol<32>* to,
  1025. const elfcpp::Sym<32, true>& sym,
  1026. unsigned int st_shndx,
  1027. bool is_ordinary,
  1028. unsigned int orig_st_shndx,
  1029. Object* object,
  1030. const char* version,
  1031. bool is_default_version);
  1032. #endif
  1033. #if defined(HAVE_TARGET_64_LITTLE) || defined(HAVE_TARGET_64_BIG)
  1034. template
  1035. void
  1036. Symbol_table::resolve<64, false>(
  1037. Sized_symbol<64>* to,
  1038. const elfcpp::Sym<64, false>& sym,
  1039. unsigned int st_shndx,
  1040. bool is_ordinary,
  1041. unsigned int orig_st_shndx,
  1042. Object* object,
  1043. const char* version,
  1044. bool is_default_version);
  1045. template
  1046. void
  1047. Symbol_table::resolve<64, true>(
  1048. Sized_symbol<64>* to,
  1049. const elfcpp::Sym<64, true>& sym,
  1050. unsigned int st_shndx,
  1051. bool is_ordinary,
  1052. unsigned int orig_st_shndx,
  1053. Object* object,
  1054. const char* version,
  1055. bool is_default_version);
  1056. #endif
  1057. #if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_32_BIG)
  1058. template
  1059. void
  1060. Symbol_table::override_with_special<32>(Sized_symbol<32>*,
  1061. const Sized_symbol<32>*);
  1062. #endif
  1063. #if defined(HAVE_TARGET_64_LITTLE) || defined(HAVE_TARGET_64_BIG)
  1064. template
  1065. void
  1066. Symbol_table::override_with_special<64>(Sized_symbol<64>*,
  1067. const Sized_symbol<64>*);
  1068. #endif
  1069. template
  1070. bool
  1071. Sized_symbol<32>::clone(const Sized_symbol<32>*);
  1072. template
  1073. bool
  1074. Sized_symbol<64>::clone(const Sized_symbol<64>*);
  1075. } // End namespace gold.