Use C++ 14 alignas(), init some struct fields just because of good practice.
This commit is contained in:
parent
2575eef3c0
commit
9aef7b0d6f
@ -286,13 +286,8 @@ typedef size_t upx_rsize_t;
|
||||
#endif
|
||||
|
||||
|
||||
#if (ACC_CC_MSC)
|
||||
#define __packed_struct(s) struct s {
|
||||
#define __packed_struct(s) struct alignas(1) s {
|
||||
#define __packed_struct_end() };
|
||||
#else
|
||||
#define __packed_struct(s) __acc_struct_packed(s)
|
||||
#define __packed_struct_end() __acc_struct_packed_end()
|
||||
#endif
|
||||
|
||||
#define UNUSED(var) ACC_UNUSED(var)
|
||||
#define COMPILE_TIME_ASSERT(e) ACC_COMPILE_TIME_ASSERT(e)
|
||||
|
||||
@ -67,8 +67,8 @@ public:
|
||||
public:
|
||||
// Will be set by each call to filter()/unfilter().
|
||||
// Read-only afterwards.
|
||||
upx_byte *buf;
|
||||
unsigned buf_len;
|
||||
upx_byte *buf = nullptr;
|
||||
unsigned buf_len = 0;
|
||||
|
||||
// Checksum of the buffer before applying the filter
|
||||
// or after un-applying the filter.
|
||||
@ -76,7 +76,7 @@ public:
|
||||
|
||||
// Input parameters used by various filters.
|
||||
unsigned addvalue;
|
||||
const int *preferred_ctos;
|
||||
const int *preferred_ctos = nullptr;
|
||||
|
||||
// Input/output parameters used by various filters
|
||||
unsigned char cto; // call trick offset
|
||||
|
||||
62
src/linker.h
62
src/linker.h
@ -36,32 +36,32 @@ class ElfLinker : private noncopyable {
|
||||
friend class Packer;
|
||||
|
||||
public:
|
||||
const N_BELE_RTP::AbstractPolicy *bele; // target endianness
|
||||
const N_BELE_RTP::AbstractPolicy *bele = nullptr; // target endianness
|
||||
protected:
|
||||
struct Section;
|
||||
struct Symbol;
|
||||
struct Relocation;
|
||||
|
||||
upx_byte *input;
|
||||
int inputlen;
|
||||
upx_byte *output;
|
||||
int outputlen;
|
||||
upx_byte *input = nullptr;
|
||||
int inputlen = 0;
|
||||
upx_byte *output = nullptr;
|
||||
int outputlen = 0;
|
||||
|
||||
Section *head;
|
||||
Section *tail;
|
||||
Section *head = nullptr;
|
||||
Section *tail = nullptr;
|
||||
|
||||
Section **sections;
|
||||
Symbol **symbols;
|
||||
Relocation **relocations;
|
||||
Section **sections = nullptr;
|
||||
Symbol **symbols = nullptr;
|
||||
Relocation **relocations = nullptr;
|
||||
|
||||
unsigned nsections;
|
||||
unsigned nsections_capacity;
|
||||
unsigned nsymbols;
|
||||
unsigned nsymbols_capacity;
|
||||
unsigned nrelocations;
|
||||
unsigned nrelocations_capacity;
|
||||
unsigned nsections = 0;
|
||||
unsigned nsections_capacity = 0;
|
||||
unsigned nsymbols = 0;
|
||||
unsigned nsymbols_capacity = 0;
|
||||
unsigned nrelocations = 0;
|
||||
unsigned nrelocations_capacity = 0;
|
||||
|
||||
bool reloc_done;
|
||||
bool reloc_done = false;
|
||||
|
||||
protected:
|
||||
void preprocessSections(char *start, char *end);
|
||||
@ -116,32 +116,32 @@ protected:
|
||||
};
|
||||
|
||||
struct ElfLinker::Section : private noncopyable {
|
||||
char *name;
|
||||
void *input;
|
||||
upx_byte *output;
|
||||
unsigned size;
|
||||
upx_uint64_t offset;
|
||||
unsigned p2align; // log2
|
||||
Section *next;
|
||||
char *name = nullptr;
|
||||
void *input = nullptr;
|
||||
upx_byte *output = nullptr;
|
||||
unsigned size = 0;
|
||||
upx_uint64_t offset = 0;
|
||||
unsigned p2align = 0; // log2
|
||||
Section *next = nullptr;
|
||||
|
||||
Section(const char *n, const void *i, unsigned s, unsigned a = 0);
|
||||
~Section();
|
||||
};
|
||||
|
||||
struct ElfLinker::Symbol : private noncopyable {
|
||||
char *name;
|
||||
Section *section;
|
||||
upx_uint64_t offset;
|
||||
char *name = nullptr;
|
||||
Section *section = nullptr;
|
||||
upx_uint64_t offset = 0;
|
||||
|
||||
Symbol(const char *n, Section *s, upx_uint64_t o);
|
||||
~Symbol();
|
||||
};
|
||||
|
||||
struct ElfLinker::Relocation : private noncopyable {
|
||||
const Section *section;
|
||||
unsigned offset;
|
||||
const char *type;
|
||||
const Symbol *value;
|
||||
const Section *section = nullptr;
|
||||
unsigned offset = 0;
|
||||
const char *type = nullptr;
|
||||
const Symbol *value = nullptr;
|
||||
upx_uint64_t add; // used in .rela relocations
|
||||
|
||||
Relocation(const Section *s, unsigned o, const char *t, const Symbol *v, upx_uint64_t a);
|
||||
|
||||
10
src/packer.h
10
src/packer.h
@ -289,8 +289,8 @@ protected:
|
||||
void set_te64(void *p, upx_uint64_t v) const { bele->set64(p, v); }
|
||||
|
||||
protected:
|
||||
const N_BELE_RTP::AbstractPolicy *bele; // target endianness
|
||||
InputFile *fi;
|
||||
const N_BELE_RTP::AbstractPolicy *bele = nullptr; // target endianness
|
||||
InputFile *fi = nullptr;
|
||||
off_t file_size; // will get set by constructor
|
||||
PackHeader ph; // must be filled by canUnpack()
|
||||
int ph_format;
|
||||
@ -301,14 +301,14 @@ protected:
|
||||
MemBuffer obuf; // output
|
||||
|
||||
// UI handler
|
||||
UiPacker *uip;
|
||||
UiPacker *uip = nullptr;
|
||||
|
||||
// linker
|
||||
Linker *linker;
|
||||
Linker *linker = nullptr;
|
||||
|
||||
private:
|
||||
// private to checkPatch()
|
||||
void *last_patch;
|
||||
void *last_patch = nullptr;
|
||||
int last_patch_len;
|
||||
int last_patch_off;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user