Use C++ 14 alignas(), init some struct fields just because of good practice.

This commit is contained in:
Markus F.X.J. Oberhumer
2021-01-04 21:02:07 +01:00
parent 2575eef3c0
commit 9aef7b0d6f
5 changed files with 42 additions and 47 deletions
+31 -31
View File
@@ -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);