28 #ifndef __UPX_LINKER_H 29 #define __UPX_LINKER_H 1 58 unsigned nsections_capacity;
60 unsigned nsymbols_capacity;
61 unsigned nrelocations;
62 unsigned nrelocations_capacity;
67 void preprocessSections(
char *start,
char *end);
68 void preprocessSymbols(
char *start,
char *end);
69 void preprocessRelocations(
char *start,
char *end);
70 Section *findSection(
const char *name,
bool fatal =
true)
const;
71 Symbol *findSymbol(
const char *name,
bool fatal =
true)
const;
73 Symbol *addSymbol(
const char *name,
const char *section, upx_uint64_t offset);
74 Relocation *addRelocation(
const char *section,
unsigned off,
const char *type,
75 const char *symbol, upx_uint64_t add);
81 virtual void init(
const void *pdata,
int plen);
83 virtual int addLoader(
const char *sname);
84 void addLoader(
const char *s, va_list ap);
85 #if 1 && (ACC_CC_CLANG || (ACC_CC_GNUC >= 0x040100)) 86 void __acc_cdecl_va addLoaderVA(
const char *s, ...) __attribute__((__sentinel__));
88 void __acc_cdecl_va addLoaderVA(
const char *s, ...);
90 virtual Section *addSection(
const char *sname,
const void *sdata,
int slen,
unsigned p2align);
91 virtual int getSection(
const char *sname,
int *slen = NULL)
const;
92 virtual int getSectionSize(
const char *sname)
const;
93 virtual upx_byte *getLoader(
int *llen = NULL)
const;
94 virtual void defineSymbol(
const char *name, upx_uint64_t value);
95 virtual upx_uint64_t getSymbolOffset(
const char *)
const;
97 virtual void dumpSymbol(
const Symbol *,
unsigned flags, FILE *fp)
const;
98 virtual void dumpSymbols(
unsigned flags = 0, FILE *fp = NULL)
const;
100 void alignWithByte(
unsigned len,
unsigned char b);
101 virtual void alignCode(
unsigned len) { alignWithByte(len, 0); }
102 virtual void alignData(
unsigned len) { alignWithByte(len, 0); }
105 virtual void relocate();
106 virtual void relocate1(
const Relocation *, upx_byte *location, upx_uint64_t value,
110 unsigned get_te16(
const void *p)
const {
return bele->get16(p); }
111 unsigned get_te32(
const void *p)
const {
return bele->get32(p); }
112 upx_uint64_t get_te64(
const void *p)
const {
return bele->get64(p); }
113 void set_te16(
void *p,
unsigned v)
const { bele->set16(p, v); }
114 void set_te32(
void *p,
unsigned v)
const { bele->set32(p, v); }
115 void set_te64(
void *p, upx_uint64_t v)
const { bele->set64(p, v); }
127 Section(
const char *n,
const void *i,
unsigned s,
unsigned a = 0);
158 virtual void alignCode(
unsigned len) { alignWithByte(len, 0x90); }
159 virtual void relocate1(
const Relocation *, upx_byte *location, upx_uint64_t value,
170 virtual void relocate1(
const Relocation *, upx_byte *location, upx_uint64_t value,
178 virtual void relocate1(
const Relocation *, upx_byte *location, upx_uint64_t value,
186 virtual void relocate1(
const Relocation *, upx_byte *location, upx_uint64_t value,
197 virtual void alignCode(
unsigned len);
198 virtual void relocate1(
const Relocation *, upx_byte *location, upx_uint64_t value,
209 virtual void relocate1(
const Relocation *, upx_byte *location, upx_uint64_t value,
217 virtual void relocate1(
const Relocation *, upx_byte *location, upx_uint64_t value,
228 virtual void relocate1(
const Relocation *, upx_byte *location, upx_uint64_t value,
236 virtual void relocate1(
const Relocation *, upx_byte *location, upx_uint64_t value,
244 virtual void alignCode(
unsigned len) { alignWithByte(len, 0x90); }
245 virtual void relocate1(
const Relocation *, upx_byte *location, upx_uint64_t value,