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