1 // object.h -- support for an object file for linking in gold -*- C++ -*-
7 #include "targetsize.h"
14 // Data to pass from read_symbols() to add_symbols().
16 struct Read_symbols_data
20 // Size of symbol data in bytes.
23 File_view
* symbol_names
;
24 // Size of symbol name data in bytes.
25 off_t symbol_names_size
;
28 // Object is an interface which represents either a 32-bit or a 64-bit
29 // object file. The actual instantiations are Sized_object<32> and
35 // NAME is the name of the object as we would report it to the user
36 // (e.g., libfoo.a(bar.o) if this is in an archive. INPUT_FILE is
37 // used to read the file. OFFSET is the offset within the input
38 // file--0 for a .o or .so file, something else for a .a file.
39 Object(const std::string
& name
, Input_file
* input_file
, off_t offset
= 0)
40 : name_(name
), input_file_(input_file
), offset_(offset
)
48 { return this->name_
; }
50 // Read the symbol and relocation information.
53 { return this->do_read_symbols(); }
55 // Add symbol information to the global symbol table.
57 add_symbols(Read_symbols_data rd
)
58 { this->do_add_symbols(rd
); }
61 // Read the symbols--implemented by child class.
62 virtual Read_symbols_data
63 do_read_symbols() = 0;
65 // Add symbol information to the global symbol table--implemented by
68 do_add_symbols(Read_symbols_data
) = 0;
73 { return this->input_file_
; }
75 // Get the offset into the file.
78 { return this->offset_
; }
80 // Get a view into the underlying file.
82 get_view(off_t start
, off_t size
);
84 // Read data from the underlying file.
86 read(off_t start
, off_t size
, void* p
);
88 // Get a lasting view into the underlying file.
90 get_lasting_view(off_t start
, off_t size
);
93 // This class may not be copied.
94 Object(const Object
&);
95 Object
& operator=(const Object
&);
97 // Name of object as printed to use.
99 // For reading the file.
100 Input_file
* input_file_
;
101 // Offset within the file--0 for an object file, non-0 for an
106 // The functions of Object which are size specific.
108 template<int size
, bool big_endian
>
109 class Sized_object
: public Object
112 Sized_object(const std::string
& name
, Input_file
* input_file
, off_t offset
,
113 const typename
elfcpp::Ehdr
<size
, big_endian
>&);
118 setup(const typename
elfcpp::Ehdr
<size
, big_endian
>&);
124 do_add_symbols(Read_symbols_data
);
127 // This object may not be copied.
128 Sized_object(const Sized_object
&);
129 Sized_object
& operator=(const Sized_object
&);
131 // ELF file header EI_OSABI field.
132 unsigned char osabi_
;
133 // ELF file header EI_ABIVERSION field.
134 unsigned char abiversion_
;
135 // ELF file header e_machine field.
136 elfcpp::Elf_Half machine_
;
137 // ELF file header e_flags field.
139 // Target functions--may be NULL.
141 // File offset of section header table.
143 // Number of input sections.
145 // Offset of SHT_STRTAB section holding section names.
146 unsigned int shstrndx_
;
147 // Index of SHT_SYMTAB section.
148 unsigned int symtab_shnum_
;
151 // Return an Object appropriate for the input file. P is BYTES long,
152 // and holds the ELF header.
154 extern Object
* make_elf_object(const std::string
& name
, Input_file
*,
155 off_t offset
, const unsigned char* p
,
158 } // end namespace gold
160 #endif // !defined(GOLD_OBJECT_H)
This page took 0.035281 seconds and 4 git commands to generate.