1 /* Copyright (C) 2021 Free Software Foundation, Inc.
4 This file is part of GNU Binutils.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, 51 Franklin Street - Fifth Floor, Boston,
19 MA 02110-1301, USA. */
24 // A Segment object represents a segment of the program text.
30 #define JAVA_COMPILED_METHODS "JAVA_COMPILED_METHODS"
31 #define DYNFUNC_SEGMENT "DYNAMIC_FUNCTIONS"
32 #define SEG_FLAG_DYNAMIC 0x01
33 #define SEG_FLAG_JVM 0x02
34 #define SEG_FLAG_OMP 0x04
35 #define SEG_FLAG_EXE 0x08
36 #define SEG_FLAG_REORDER 0x10
38 /* Hash name for all comparable executions */
39 #define COMP_EXE_NAME "<COMP_EXE_NAME>"
46 template <typename Key_t, typename Value_t> class HashMap;
47 template <typename Key_t, typename Value_t> class Map;
48 template <class ITEM> class Vector;
57 class LoadObject : public HistableFile, public DbeLock
61 // The various segments types.
73 // These codes are stored in *.archive files
92 LoadObject (const char *loname);
94 static LoadObject *create_item (const char *nm, int64_t chksum);
95 static LoadObject *create_item (const char *nm, const char *_runTimePath, DbeFile *df);
97 virtual ~LoadObject ();
98 virtual void set_name (char *string);
99 virtual uint64_t get_addr ();
100 virtual Vector<Histable*> *get_comparable_objs ();
102 virtual Histable_type
121 set_archname (char *aname)
130 return isRelocatable;
133 bool compare (const char *nm, int64_t _checksum);
134 int compare (const char *_path, const char *_runTimePath, DbeFile *df);
135 void set_platform (Platform_t pltf, int wsz);
136 void dump_functions (FILE *);
137 int get_index (Function *func);
138 char *get_alias (Function *func);
139 DbeInstr *find_dbeinstr (uint64_t file_off);
140 Function *find_function (uint64_t offset);
141 Function *find_function (char *fname);
142 Function *find_function (char *fname, unsigned int chksum);
143 Module *find_module (char *mname);
144 Module *get_comparable_Module (Module *mod);
145 void append_module (Module *mod);
147 Stabs *openDebugInfo (char *fname, Stabs::Stab_status *stp = NULL);
148 Arch_status read_stabs ();
149 Arch_status sync_read_stabs ();
150 void post_process_functions ();
151 char *status_str (Arch_status rv, char *arg = NULL);
152 Function *get_hide_function ();
153 DbeInstr *get_hide_instr (DbeInstr *instr);
154 uint32_t get_checksum ();
157 fetch_warnings (void) // fetch the queue of warning messages
159 return warnq->fetch ();
163 fetch_comments (void) // fetch the queue of comment messages
165 return commentq->fetch ();
168 unsigned int flags; // SEG_FLAG_*
170 bool need_swap_endian;
171 int seg_idx; // for compatibility (ADDRESS)
173 int64_t size; // size of loadobject in bytes
174 int64_t max_size; // Maximum size of loadobject in bytes
175 int64_t min_size; // Min size of loadobject in bytes.
176 Vector<Function*> *functions; // Ordered list of functions
177 Vector<Module*> *seg_modules; // list of modules
178 HashMap<char*, Module*> *modules;
179 Module *noname; // Module pointer to unknown name
180 Platform_t platform; // Sparc, Sparcv9, Intel
181 WSize_t wsize; // word size: 32,64
183 HashMap<char*, Function*> *comp_funcs; // list of comparable functions
184 Experiment *firstExp;
186 time_t mtime; // file timestamp (in seconds)
187 int64_t checksum; // file checksum
192 DbeInstr **instHTable; // hash table for DbeInstr
193 char *pathname; // User name of object file
194 ino64_t inode; // inode number of segment file
195 bool isRelocatable; // is relocatable .o
196 char *arch_name; // .archive name
199 Function **funcHTable; // hash table for functions
200 Function *h_function; // hide pseudo function
201 DbeInstr *h_instr; // hide pseudo instr
202 HashMap<char*, Module*> *seg_modules_map; // to find a comparable module
204 static int func_compare (const void *p1, const void *p2);
206 void init_datatypes ();
207 void update_datatypes (Module*, Vaddr, uint32_t datatype_id);
210 #endif /* _LOADOBJECT_H */