aboutsummaryrefslogtreecommitdiff
path: root/gold/layout.h
diff options
context:
space:
mode:
authorCary Coutant <ccoutant@google.com>2008-05-01 01:23:21 +0000
committerCary Coutant <ccoutant@google.com>2008-05-01 01:23:21 +0000
commite94cf1277329c4eaba3b398b446e693550463c77 (patch)
treec3264396a84db5f5c415e8465cef5d21f58db7cf /gold/layout.h
parent1af5d7ceb5960c714e55c2fdf80c22b52db84738 (diff)
downloadgdb-e94cf1277329c4eaba3b398b446e693550463c77.zip
gdb-e94cf1277329c4eaba3b398b446e693550463c77.tar.gz
gdb-e94cf1277329c4eaba3b398b446e693550463c77.tar.bz2
* layout.cc (Layout::include_section): Refactored check for debug
info section. (Layout::add_comdat): Add new parameters. Change type of signature parameter. Add object and shndx to signatures table. (Layout::find_kept_object): New function. * layout.h: Include <cstring>. (Layout::is_debug_info_section): New function. (Layout::add_comdat): Add new parameters. (Layout::find_kept_object): New function. (Layout::Kept_section): New struct. (Layout::Signatures): Change type of map range. * object.cc (Relobj::output_section_address): New function. (Sized_relobj::include_section_group): Add new parameters. Change calls to Layout::add_comdat. Change to build table of kept comdat groups and table mapping discarded sections to kept sections. (Sized_relobj::include_linkonce_section): Likewise. Add new parameter. (Sized_relobj::do_layout): Change calls to include_section_group and include_linkonce_section. (Sized_relobj::do_finalize_local_symbols): Do not set local symbol value to zero when section is discarded. (Sized_relobj::map_to_kept_section): New function. * object.h (Relobj::output_section_address): New function. (Relobj::Comdat_group): New type. (Relobj::find_comdat_group): New function. (Relobj::Comdat_group_table): New type. (Relobj::Kept_comdat_section): New type. (Relobj::Kept_comdat_section_table): New type. (Relobj::add_comdat_group): New function. (Relobj::set_kept_comdat_section): New function. (Relobj::get_kept_comdat_section): New function. (Relobj::comdat_groups_): New field. (Relobj::kept_comdat_sections_): New field. (Symbol_value::input_value): Update comment. (Sized_relobj::map_to_kept_section) New function. (Sized_relobj::include_linkonce_section): Add new parameter. * target-reloc.h (Comdat_behavior): New type. (get_comdat_behavior): New function. (relocate_section): Add code to map a discarded section to the corresponding kept section when applying a relocation.
Diffstat (limited to 'gold/layout.h')
-rw-r--r--gold/layout.h34
1 files changed, 32 insertions, 2 deletions
diff --git a/gold/layout.h b/gold/layout.h
index efa8b61..8584a0c 100644
--- a/gold/layout.h
+++ b/gold/layout.h
@@ -23,6 +23,7 @@
#ifndef GOLD_LAYOUT_H
#define GOLD_LAYOUT_H
+#include <cstring>
#include <list>
#include <string>
#include <utility>
@@ -212,12 +213,29 @@ class Layout
is_linkonce(const char* name)
{ return strncmp(name, ".gnu.linkonce", sizeof(".gnu.linkonce") - 1) == 0; }
+ // Return true if a section is a debugging section.
+ static inline bool
+ is_debug_info_section(const char* name)
+ {
+ // Debugging sections can only be recognized by name.
+ return (strncmp(name, ".debug", sizeof(".debug") - 1) == 0
+ || strncmp(name, ".gnu.linkonce.wi.",
+ sizeof(".gnu.linkonce.wi.") - 1) == 0
+ || strncmp(name, ".line", sizeof(".line") - 1) == 0
+ || strncmp(name, ".stab", sizeof(".stab") - 1) == 0);
+ }
+
// Record the signature of a comdat section, and return whether to
// include it in the link. The GROUP parameter is true for a
// section group signature, false for a signature derived from a
// .gnu.linkonce section.
bool
- add_comdat(const char*, bool group);
+ add_comdat(Relobj*, unsigned int, const std::string&, bool group);
+
+ // Find the given comdat signature, and return the object and section
+ // index of the kept group.
+ Relobj*
+ find_kept_object(const std::string&, unsigned int*) const;
// Finalize the layout after all the input sections have been added.
off_t
@@ -550,7 +568,19 @@ class Layout
segment_precedes(const Output_segment* seg1, const Output_segment* seg2);
// A mapping used for group signatures.
- typedef Unordered_map<std::string, bool> Signatures;
+ struct Kept_section
+ {
+ Kept_section()
+ : object_(NULL), shndx_(0), group_(false)
+ { }
+ Kept_section(Relobj* object, unsigned int shndx, bool group)
+ : object_(object), shndx_(shndx), group_(group)
+ { }
+ Relobj* object_;
+ unsigned int shndx_;
+ bool group_;
+ };
+ typedef Unordered_map<std::string, Kept_section> Signatures;
// Mapping from input section name/type/flags to output section. We
// use canonicalized strings here.