2 * Copyright (c) 2002-2004 The Regents of The University of Michigan
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 * Authors: Nathan Binkert
32 #ifndef __BASE_LOADER_OBJECT_FILE_HH__
33 #define __BASE_LOADER_OBJECT_FILE_HH__
37 #include "base/loader/image_file.hh"
38 #include "base/loader/image_file_data.hh"
39 #include "base/loader/memory_image.hh"
40 #include "base/logging.hh"
41 #include "base/types.hh"
45 class ObjectFile : public ImageFile
75 Arch arch = UnknownArch;
76 OpSys opSys = UnknownOpSys;
78 ObjectFile(ImageFileDataPtr ifd);
81 virtual ~ObjectFile() {};
84 loadAllSymbols(SymbolTable *symtab, Addr base=0,
85 Addr offset=0, Addr mask=MaxAddr)
90 loadGlobalSymbols(SymbolTable *symtab, Addr base=0,
91 Addr offset=0, Addr mask=MaxAddr)
96 loadLocalSymbols(SymbolTable *symtab, Addr base=0,
97 Addr offset=0, Addr mask=MaxAddr)
102 loadWeakSymbols(SymbolTable *symtab, Addr base=0,
103 Addr offset=0, Addr mask=MaxAddr)
108 virtual ObjectFile *getInterpreter() const { return nullptr; }
109 virtual bool relocatable() const { return false; }
113 panic("mapSize() should only be called on relocatable objects\n");
116 updateBias(Addr bias_addr)
118 panic("updateBias() should only be called on relocatable objects\n");
120 virtual Addr bias() const { return 0; }
122 virtual bool hasTLS() { return false; }
124 Arch getArch() const { return arch; }
125 OpSys getOpSys() const { return opSys; }
131 Addr entryPoint() const { return entry; }
134 class ObjectFileFormat
140 ObjectFileFormat(const ObjectFileFormat &) = delete;
141 void operator=(const ObjectFileFormat &) = delete;
143 virtual ObjectFile *load(ImageFileDataPtr data) = 0;
146 ObjectFile *createObjectFile(const std::string &fname, bool raw=false);
148 #endif // __BASE_LOADER_OBJECT_FILE_HH__