clang-format
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
* @markus-oberhumer @jreiser
|
* @markus-oberhumer @jreiser
|
||||||
|
|
||||||
/src/p_elf* @jreiser
|
|
||||||
/src/p_lx_* @jreiser
|
/src/p_lx_* @jreiser
|
||||||
/src/p_mach* @jreiser
|
/src/p_mach* @jreiser
|
||||||
/src/p_unix* @jreiser
|
/src/p_unix* @jreiser
|
||||||
|
|||||||
+1
-1
@@ -98,7 +98,7 @@ endif
|
|||||||
ifeq ($(shell uname),Linux)
|
ifeq ($(shell uname),Linux)
|
||||||
# Markus loves clang-format, but John hates it; find a compromise
|
# Markus loves clang-format, but John hates it; find a compromise
|
||||||
CLANG_FORMAT_EXCLUDE_FILES += miniacc.h stub/%.h
|
CLANG_FORMAT_EXCLUDE_FILES += miniacc.h stub/%.h
|
||||||
CLANG_FORMAT_EXCLUDE_FILES += p_elf.h p_elf_enum.h p_lx_% p_mach% p_unix% p_vmlin%
|
CLANG_FORMAT_EXCLUDE_FILES += p_lx_% p_mach% p_unix% p_vmlin%
|
||||||
CLANG_FORMAT_FILES := $(sort $(wildcard *.[ch]* ../maint/src/*.[ch]* */*.[ch]*))
|
CLANG_FORMAT_FILES := $(sort $(wildcard *.[ch]* ../maint/src/*.[ch]* */*.[ch]*))
|
||||||
CLANG_FORMAT_FILES += $(sort $(wildcard stub/tools/*/*.[ch]*))
|
CLANG_FORMAT_FILES += $(sort $(wildcard stub/tools/*/*.[ch]*))
|
||||||
CLANG_FORMAT_FILES += $(sort $(wildcard ../misc/cmake/try_compile/*.[ch]*))
|
CLANG_FORMAT_FILES += $(sort $(wildcard ../misc/cmake/try_compile/*.[ch]*))
|
||||||
|
|||||||
+9
-29
@@ -35,8 +35,7 @@ namespace N_Elf {
|
|||||||
|
|
||||||
// integral types
|
// integral types
|
||||||
template <class THalf, class TWord, class TXword, class TAddr, class TOff>
|
template <class THalf, class TWord, class TXword, class TAddr, class TOff>
|
||||||
struct ElfITypes
|
struct ElfITypes {
|
||||||
{
|
|
||||||
typedef THalf Half;
|
typedef THalf Half;
|
||||||
typedef TWord Word;
|
typedef TWord Word;
|
||||||
typedef TXword Xword;
|
typedef TXword Xword;
|
||||||
@@ -46,7 +45,6 @@ struct ElfITypes
|
|||||||
typedef THalf Versym;
|
typedef THalf Versym;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// The ELF file header. This appears at the start of every ELF file.
|
// The ELF file header. This appears at the start of every ELF file.
|
||||||
template <class TElfITypes>
|
template <class TElfITypes>
|
||||||
packed_struct(Ehdr) {
|
packed_struct(Ehdr) {
|
||||||
@@ -74,7 +72,6 @@ packed_struct(Ehdr) {
|
|||||||
#include "p_elf_enum.h"
|
#include "p_elf_enum.h"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template <class TElfITypes>
|
template <class TElfITypes>
|
||||||
packed_struct(Dyn) {
|
packed_struct(Dyn) {
|
||||||
typedef typename TElfITypes::Xword Xword;
|
typedef typename TElfITypes::Xword Xword;
|
||||||
@@ -87,7 +84,6 @@ packed_struct(Dyn) {
|
|||||||
#include "p_elf_enum.h"
|
#include "p_elf_enum.h"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template <class TElfITypes>
|
template <class TElfITypes>
|
||||||
packed_struct(Rel) {
|
packed_struct(Rel) {
|
||||||
typedef typename TElfITypes::Xword Xword;
|
typedef typename TElfITypes::Xword Xword;
|
||||||
@@ -97,7 +93,6 @@ packed_struct(Rel) {
|
|||||||
Xword r_info;
|
Xword r_info;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template <class TElfITypes>
|
template <class TElfITypes>
|
||||||
packed_struct(Rela) {
|
packed_struct(Rela) {
|
||||||
typedef typename TElfITypes::Xword Xword;
|
typedef typename TElfITypes::Xword Xword;
|
||||||
@@ -108,7 +103,6 @@ packed_struct(Rela) {
|
|||||||
Xword r_addend;
|
Xword r_addend;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template <class TElfITypes>
|
template <class TElfITypes>
|
||||||
packed_struct(External_Note) {
|
packed_struct(External_Note) {
|
||||||
typedef typename TElfITypes::Word Word;
|
typedef typename TElfITypes::Word Word;
|
||||||
@@ -120,10 +114,8 @@ packed_struct(External_Note) {
|
|||||||
// char xn_data[M]; // aligned to 0 mod 4
|
// char xn_data[M]; // aligned to 0 mod 4
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace N_Elf
|
} // namespace N_Elf
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
// N_Elf32
|
// N_Elf32
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
@@ -149,7 +141,6 @@ packed_struct(Phdr) {
|
|||||||
#include "p_elf_enum.h"
|
#include "p_elf_enum.h"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template <class TElfITypes>
|
template <class TElfITypes>
|
||||||
packed_struct(Shdr) {
|
packed_struct(Shdr) {
|
||||||
typedef typename TElfITypes::Word Word;
|
typedef typename TElfITypes::Word Word;
|
||||||
@@ -171,7 +162,6 @@ packed_struct(Shdr) {
|
|||||||
#include "p_elf_enum.h"
|
#include "p_elf_enum.h"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template <class TElfITypes>
|
template <class TElfITypes>
|
||||||
packed_struct(Sym) {
|
packed_struct(Sym) {
|
||||||
typedef typename TElfITypes::Word Word;
|
typedef typename TElfITypes::Word Word;
|
||||||
@@ -190,14 +180,13 @@ packed_struct(Sym) {
|
|||||||
|
|
||||||
static unsigned int get_st_bind(unsigned x) { return 0xf & (x >> 4); }
|
static unsigned int get_st_bind(unsigned x) { return 0xf & (x >> 4); }
|
||||||
static unsigned int get_st_type(unsigned x) { return 0xf & x; }
|
static unsigned int get_st_type(unsigned x) { return 0xf & x; }
|
||||||
static unsigned char make_st_info(unsigned bind, unsigned type)
|
static unsigned char make_st_info(unsigned bind, unsigned type) {
|
||||||
{ return (unsigned char) (((bind<<4) + (0xf & type)) & 0xff); }
|
return (unsigned char) (((bind << 4) + (0xf & type)) & 0xff);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace N_Elf32
|
} // namespace N_Elf32
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
// N_Elf64
|
// N_Elf64
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
@@ -224,7 +213,6 @@ packed_struct(Phdr) {
|
|||||||
#include "p_elf_enum.h"
|
#include "p_elf_enum.h"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template <class TElfITypes>
|
template <class TElfITypes>
|
||||||
packed_struct(Shdr) {
|
packed_struct(Shdr) {
|
||||||
typedef typename TElfITypes::Word Word;
|
typedef typename TElfITypes::Word Word;
|
||||||
@@ -247,7 +235,6 @@ packed_struct(Shdr) {
|
|||||||
#include "p_elf_enum.h"
|
#include "p_elf_enum.h"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template <class TElfITypes>
|
template <class TElfITypes>
|
||||||
packed_struct(Sym) {
|
packed_struct(Sym) {
|
||||||
typedef typename TElfITypes::Word Word;
|
typedef typename TElfITypes::Word Word;
|
||||||
@@ -267,14 +254,13 @@ packed_struct(Sym) {
|
|||||||
|
|
||||||
static unsigned int get_st_bind(unsigned x) { return 0xf & (x >> 4); }
|
static unsigned int get_st_bind(unsigned x) { return 0xf & (x >> 4); }
|
||||||
static unsigned int get_st_type(unsigned x) { return 0xf & x; }
|
static unsigned int get_st_type(unsigned x) { return 0xf & x; }
|
||||||
static unsigned char make_st_info(unsigned bind, unsigned type)
|
static unsigned char make_st_info(unsigned bind, unsigned type) {
|
||||||
{ return (unsigned char) (((bind<<4) + (0xf & type)) & 0xff); }
|
return (unsigned char) (((bind << 4) + (0xf & type)) & 0xff);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace N_Elf64
|
} // namespace N_Elf64
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
// aggregate types into an ElfClass
|
// aggregate types into an ElfClass
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
@@ -282,8 +268,7 @@ packed_struct(Sym) {
|
|||||||
namespace N_Elf {
|
namespace N_Elf {
|
||||||
|
|
||||||
template <class TP>
|
template <class TP>
|
||||||
struct ElfClass_32
|
struct ElfClass_32 {
|
||||||
{
|
|
||||||
typedef TP BeLePolicy;
|
typedef TP BeLePolicy;
|
||||||
|
|
||||||
// integral types (target endianness)
|
// integral types (target endianness)
|
||||||
@@ -323,10 +308,8 @@ struct ElfClass_32
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template <class TP>
|
template <class TP>
|
||||||
struct ElfClass_64
|
struct ElfClass_64 {
|
||||||
{
|
|
||||||
typedef TP BeLePolicy;
|
typedef TP BeLePolicy;
|
||||||
|
|
||||||
// integral types (target endianness)
|
// integral types (target endianness)
|
||||||
@@ -366,10 +349,8 @@ struct ElfClass_64
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace N_Elf
|
} // namespace N_Elf
|
||||||
|
|
||||||
|
|
||||||
typedef N_Elf::ElfClass_32<N_BELE_CTP::HostPolicy> ElfClass_Host32;
|
typedef N_Elf::ElfClass_32<N_BELE_CTP::HostPolicy> ElfClass_Host32;
|
||||||
typedef N_Elf::ElfClass_64<N_BELE_CTP::HostPolicy> ElfClass_Host64;
|
typedef N_Elf::ElfClass_64<N_BELE_CTP::HostPolicy> ElfClass_Host64;
|
||||||
typedef N_Elf::ElfClass_32<N_BELE_CTP::BEPolicy> ElfClass_BE32;
|
typedef N_Elf::ElfClass_32<N_BELE_CTP::BEPolicy> ElfClass_BE32;
|
||||||
@@ -377,7 +358,6 @@ typedef N_Elf::ElfClass_64<N_BELE_CTP::BEPolicy> ElfClass_BE64;
|
|||||||
typedef N_Elf::ElfClass_32<N_BELE_CTP::LEPolicy> ElfClass_LE32;
|
typedef N_Elf::ElfClass_32<N_BELE_CTP::LEPolicy> ElfClass_LE32;
|
||||||
typedef N_Elf::ElfClass_64<N_BELE_CTP::LEPolicy> ElfClass_LE64;
|
typedef N_Elf::ElfClass_64<N_BELE_CTP::LEPolicy> ElfClass_LE64;
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
// shortcuts
|
// shortcuts
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|||||||
+6
-10
@@ -25,7 +25,6 @@
|
|||||||
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
// Use the preprocessor to work around
|
// Use the preprocessor to work around
|
||||||
// - that the types embedding these enums have to be PODs, and
|
// - that the types embedding these enums have to be PODs, and
|
||||||
@@ -88,7 +87,6 @@
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef WANT_PHDR_ENUM
|
#ifdef WANT_PHDR_ENUM
|
||||||
#undef WANT_PHDR_ENUM
|
#undef WANT_PHDR_ENUM
|
||||||
enum { // p_type
|
enum { // p_type
|
||||||
@@ -110,7 +108,6 @@
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef WANT_SHDR_ENUM
|
#ifdef WANT_SHDR_ENUM
|
||||||
#undef WANT_SHDR_ENUM
|
#undef WANT_SHDR_ENUM
|
||||||
enum { // sh_type
|
enum { // sh_type
|
||||||
@@ -154,7 +151,6 @@
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef WANT_DYN_ENUM
|
#ifdef WANT_DYN_ENUM
|
||||||
#undef WANT_DYN_ENUM
|
#undef WANT_DYN_ENUM
|
||||||
enum { // d_tag
|
enum { // d_tag
|
||||||
@@ -200,7 +196,6 @@
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef WANT_SYM_ENUM
|
#ifdef WANT_SYM_ENUM
|
||||||
#undef WANT_SYM_ENUM
|
#undef WANT_SYM_ENUM
|
||||||
enum { // st_bind (high 4 bits of st_info)
|
enum { // st_bind (high 4 bits of st_info)
|
||||||
@@ -233,17 +228,18 @@
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef WANT_REL_ENUM //{
|
#ifdef WANT_REL_ENUM //{
|
||||||
#undef WANT_REL_ENUM
|
#undef WANT_REL_ENUM
|
||||||
static inline unsigned ELF32_R_TYPE(unsigned x) { return 0xff & x; }
|
static inline unsigned ELF32_R_TYPE(unsigned x) { return 0xff & x; }
|
||||||
static inline unsigned ELF64_R_TYPE(upx_uint64_t x) { return 0xffffffff & (unsigned) x; }
|
static inline unsigned ELF64_R_TYPE(upx_uint64_t x) { return 0xffffffff & (unsigned) x; }
|
||||||
static inline unsigned ELF32_R_SYM(unsigned x) { return x >> 8; }
|
static inline unsigned ELF32_R_SYM(unsigned x) { return x >> 8; }
|
||||||
static inline unsigned ELF64_R_SYM(upx_uint64_t x) { return x >> 32; }
|
static inline unsigned ELF64_R_SYM(upx_uint64_t x) { return x >> 32; }
|
||||||
static inline unsigned ELF32_R_INFO(unsigned sym, unsigned type)
|
static inline unsigned ELF32_R_INFO(unsigned sym, unsigned type) {
|
||||||
{ return (sym << 8) + (type & 0xff); }
|
return (sym << 8) + (type & 0xff);
|
||||||
static inline upx_int64_t ELF64_R_INFO(unsigned sym, unsigned type)
|
}
|
||||||
{ return ((upx_uint64_t)sym << 32) + type; }
|
static inline upx_int64_t ELF64_R_INFO(unsigned sym, unsigned type) {
|
||||||
|
return ((upx_uint64_t) sym << 32) + type;
|
||||||
|
}
|
||||||
|
|
||||||
#undef R_PPC_RELATIVE
|
#undef R_PPC_RELATIVE
|
||||||
#undef R_PPC64_RELATIVE
|
#undef R_PPC64_RELATIVE
|
||||||
|
|||||||
Reference in New Issue
Block a user