all: minor updates

This commit is contained in:
Markus F.X.J. Oberhumer
2022-12-15 16:20:22 +01:00
parent 9934e33b99
commit c23c7a9379
7 changed files with 29 additions and 18 deletions
+9
View File
@@ -355,6 +355,15 @@ inline const T& UPX_MAX(const T& a, const T& b) { if (a < b) return b; return a;
template <class T>
inline const T& UPX_MIN(const T& a, const T& b) { if (a < b) return a; return b; }
template <size_t TypeSize>
struct USizeOfTypeImpl {
__acc_static_forceinline constexpr unsigned value() {
COMPILE_TIME_ASSERT(TypeSize >= 1 && TypeSize <= 64 * 1024); // arbitrary limit
return ACC_ICONV(unsigned, TypeSize);
}
};
#define usizeof(type) (USizeOfTypeImpl<sizeof(type)>::value())
ACC_COMPILE_TIME_ASSERT_HEADER(usizeof(int) == 4)
// An Array allocates memory on the heap, and automatically
// gets destructed when leaving scope or on exceptions.
+1 -3
View File
@@ -62,8 +62,6 @@ unsigned char PackLinuxElf::o_shstrtab[] = { \
/*offset 20*/ '.','s','h','s','t','r','t','a','b','\0'
};
#define usizeof(x) ((unsigned) sizeof(x))
static unsigned
umin(unsigned a, unsigned b)
{
@@ -5178,7 +5176,7 @@ void PackLinuxElf64::unpack(OutputFile *fo)
fi->seek(overlay_offset - sizeof(l_info), SEEK_SET);
fi->readx(&linfo, sizeof(linfo));
if (UPX_MAGIC_LE32 != get_le32(&linfo.l_magic)) {
unsigned const *const lp = (unsigned const *)(void const *)&linfo;
NE32 const *const lp = (NE32 const *)(void const *)&linfo;
// Workaround for bug of extra linfo by some asl_pack2_Shdrs().
if (0==lp[0] && 0==lp[1] && 0==lp[2]) { // looks like blank extra
fi->readx(&linfo, sizeof(linfo));
-2
View File
@@ -49,8 +49,6 @@
#define DT_STRSZ Elf32_Dyn::DT_STRSZ
#endif
#define usizeof(x) ((unsigned) sizeof(x))
/*************************************************************************
// linux/386 (generic "execve" format)
+3 -2
View File
@@ -25,8 +25,9 @@
<markus@oberhumer.com> <ezerotven+github@gmail.com>
*/
#ifndef __UPX_P_TMT_H
#define __UPX_P_TMT_H 1
#pragma once
#ifndef UPX_P_TMT_H__
#define UPX_P_TMT_H__ 1
/*************************************************************************
// tmt/adam
+3 -2
View File
@@ -25,8 +25,9 @@
<markus@oberhumer.com> <ezerotven+github@gmail.com>
*/
#ifndef __UPX_P_TOS_H
#define __UPX_P_TOS_H 1
#pragma once
#ifndef UPX_P_TOS_H__
#define UPX_P_TOS_H__ 1
/*************************************************************************
// atari/tos