mirror of https://github.com/upx/upx.git
all: misc updates
This commit is contained in:
parent
07aa65b55e
commit
1ff0d137ab
|
@ -4,7 +4,7 @@
|
|||
# tricky, so some false positives are fine
|
||||
|
||||
[files]
|
||||
extend-exclude = ["LICENSE"]
|
||||
extend-exclude = ["LICENSE", "misc/*/packages.txt"]
|
||||
|
||||
[default.extend-identifiers]
|
||||
# misc variable names & symbols
|
||||
|
@ -12,6 +12,7 @@ acc_spawnve = "acc_spawnve"
|
|||
ba = "ba"
|
||||
fo = "fo"
|
||||
fof = "fof"
|
||||
O_WRONLY = "O_WRONLY"
|
||||
sidelen = "sidelen"
|
||||
# assembly sources
|
||||
CArry = "CArry"
|
||||
|
@ -22,6 +23,7 @@ suble = "suble"
|
|||
|
||||
# identifiers are intelligently split into words and then checked again
|
||||
[default.extend-words]
|
||||
delt = "delt"
|
||||
FO = "FO"
|
||||
fo = "fo"
|
||||
# parm is used like param
|
||||
|
@ -30,6 +32,8 @@ parm = "parm"
|
|||
# rela: ELF relocations
|
||||
RELA = "RELA"
|
||||
rela = "rela"
|
||||
# siz is used for size
|
||||
siz = "siz"
|
||||
# SEH: Structured Exception Handling
|
||||
SEH = "SEH"
|
||||
seh = "seh"
|
||||
|
|
|
@ -20,11 +20,12 @@ jobs:
|
|||
- name: 'Install extra packages'
|
||||
run: |
|
||||
uname -a; pwd; id; umask
|
||||
if ! test -e /usr/bin/python2; then
|
||||
sudo apt-get update && sudo apt-get install -y --no-install-recommends python2-minimal
|
||||
fi
|
||||
mkdir ../deps; cd ../deps; mkdir packages
|
||||
# for ubuntu-22.04: install python2-minimal
|
||||
##sudo apt-get update && sudo apt-get install -y --no-install-recommends python2-minimal
|
||||
# manually install compat libs from Ubuntu 16.04
|
||||
wget -q 'http://archive.kernel.org/ubuntu-archive/ubuntu/pool/main/m/mpfr4/libmpfr4_3.1.6-1_amd64.deb'
|
||||
wget -q 'https://archive.kernel.org/ubuntu-archive/ubuntu/pool/main/m/mpfr4/libmpfr4_3.1.6-1_amd64.deb'
|
||||
for f in ./*.deb; do dpkg -x $f ./packages; done
|
||||
sudo mv -v -n ./packages/usr/lib/x86_64-linux-gnu/lib* /usr/lib/x86_64-linux-gnu/
|
||||
rm -rf ./*.deb ./packages
|
||||
|
@ -385,8 +386,8 @@ jobs:
|
|||
- { zig_target: x86_64-macos.13-none }
|
||||
- { zig_target: x86_64-windows-gnu }
|
||||
env:
|
||||
# 2023-06-08
|
||||
ZIG_DIST_VERSION: 0.11.0-dev.3384+00ff65357
|
||||
# 2023-06-11
|
||||
ZIG_DIST_VERSION: 0.11.0-dev.3395+1e7dcaa3a
|
||||
# for zig-cc wrapper scripts (see below):
|
||||
ZIG_CPPFLAGS: -DUPX_DOCTEST_CONFIG_MULTITHREADING
|
||||
ZIG_FLAGS: ${{ matrix.zig_flags }}
|
||||
|
|
|
@ -190,6 +190,10 @@ else()
|
|||
add_definitions(-fno-strict-aliasing -fno-strict-overflow -funsigned-char)
|
||||
# disable overambitious auto-vectorization until this actually gains something
|
||||
add_definitions(-fno-tree-vectorize)
|
||||
# disable annoying clang warnings which get added by the Apple Xcode cmake generator
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "Clang" AND CMAKE_GENERATOR STREQUAL "Xcode")
|
||||
add_definitions(-Wno-shorten-64-to-32)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# compile a target with -O2 even in Debug build
|
||||
|
|
|
@ -17,3 +17,21 @@ flags=( --read-only --rm --pull=never )
|
|||
flags+=( --cap-drop=all ) # drop all capabilities
|
||||
flags+=( --network=none ) # no network needed
|
||||
podman run "${flags[@]}" "$image" bash -c $'dpkg -l | sed \'s/ *$//\' | LC_ALL=C sort'
|
||||
|
||||
echo
|
||||
echo 'Packages sorted by Installed-Size:'
|
||||
podman run "${flags[@]}" "$image" bash -c $'awk \'
|
||||
{
|
||||
if ($1 == "Architecture:") arch = $2;
|
||||
if ($1 == "Installed-Size:") size = $2;
|
||||
if ($1 == "Package:") p = $2;
|
||||
if ($1 == "") {
|
||||
printf("%9d %-40s %s\\n", size, p, arch);
|
||||
count += 1; total += size;
|
||||
arch = ""; size = 0; p = "";
|
||||
}
|
||||
}
|
||||
END {
|
||||
printf("%9d ===== TOTAL (%d packages)\\n", total, count);
|
||||
}
|
||||
\' /var/lib/dpkg/status | LC_ALL=C sort -rn'
|
||||
|
|
|
@ -17,3 +17,21 @@ flags=( --read-only --rm --pull=never )
|
|||
flags+=( --cap-drop=all ) # drop all capabilities
|
||||
flags+=( --network=none ) # no network needed
|
||||
podman run "${flags[@]}" "$image" bash -c $'dpkg -l | sed \'s/ *$//\' | LC_ALL=C sort'
|
||||
|
||||
echo
|
||||
echo 'Packages sorted by Installed-Size:'
|
||||
podman run "${flags[@]}" "$image" bash -c $'awk \'
|
||||
{
|
||||
if ($1 == "Architecture:") arch = $2;
|
||||
if ($1 == "Installed-Size:") size = $2;
|
||||
if ($1 == "Package:") p = $2;
|
||||
if ($1 == "") {
|
||||
printf("%9d %-40s %s\\n", size, p, arch);
|
||||
count += 1; total += size;
|
||||
arch = ""; size = 0; p = "";
|
||||
}
|
||||
}
|
||||
END {
|
||||
printf("%9d ===== TOTAL (%d packages)\\n", total, count);
|
||||
}
|
||||
\' /var/lib/dpkg/status | LC_ALL=C sort -rn'
|
||||
|
|
|
@ -169,8 +169,8 @@ inline void set_le24(void *p, unsigned v) noexcept {
|
|||
}
|
||||
|
||||
inline unsigned get_le26(const void *p) noexcept { return get_le32(p) & 0x03ffffff; }
|
||||
inline unsigned get_le19_5(const void *p) noexcept { return 0x7ffff & (get_le32(p) >> 5); }
|
||||
inline unsigned get_le14_5(const void *p) noexcept { return 0x03fff & (get_le32(p) >> 5); }
|
||||
inline unsigned get_le19_5(const void *p) noexcept { return 0x0007ffff & (get_le32(p) >> 5); }
|
||||
inline unsigned get_le14_5(const void *p) noexcept { return 0x00003fff & (get_le32(p) >> 5); }
|
||||
|
||||
inline void set_le26(void *p, unsigned v) noexcept {
|
||||
// preserve the top 6 bits
|
||||
|
@ -180,10 +180,10 @@ inline void set_le26(void *p, unsigned v) noexcept {
|
|||
(ne32_to_le32(v) & ne32_to_le32(0x03ffffff)));
|
||||
}
|
||||
inline void set_le19_5(void *p, unsigned v) noexcept {
|
||||
set_le32(p, (get_le32(p) & 0xff00001f) | ((v & 0x07ffff) << 5));
|
||||
set_le32(p, (get_le32(p) & 0xff00001f) | ((v & 0x0007ffff) << 5));
|
||||
}
|
||||
inline void set_le14_5(void *p, unsigned v) noexcept {
|
||||
set_le32(p, (get_le32(p) & 0xfff8001f) | ((v & 0x003fff) << 5));
|
||||
set_le32(p, (get_le32(p) & 0xfff8001f) | ((v & 0x00003fff) << 5));
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
|
|
|
@ -115,8 +115,6 @@ TEST_CASE("basic xspan usage") {
|
|||
}
|
||||
|
||||
SUBCASE("XSPAN_x_VAR") {
|
||||
XSPAN_0_VAR(char, a0, nullptr);
|
||||
|
||||
XSPAN_0_VAR(char, b0, buf);
|
||||
XSPAN_P_VAR(char, bp, buf);
|
||||
|
||||
|
@ -135,7 +133,6 @@ TEST_CASE("basic xspan usage") {
|
|||
XSPAN_0_VAR(const char, const z0p, yp);
|
||||
XSPAN_0_VAR(const char, const z0s, xs);
|
||||
|
||||
CHECK((a0 == nullptr));
|
||||
CHECK(c0 == b0);
|
||||
CHECK(cp == bp);
|
||||
CHECK(cs == bp);
|
||||
|
@ -144,9 +141,13 @@ TEST_CASE("basic xspan usage") {
|
|||
CHECK(x0 == z0p);
|
||||
CHECK(xp == z0s);
|
||||
|
||||
#if WITH_XSPAN >= 1 || __cplusplus >= 201103L
|
||||
XSPAN_0_VAR(char, a0, nullptr);
|
||||
CHECK((a0 == nullptr));
|
||||
CHECK_NOTHROW(raw_bytes(a0, 0));
|
||||
CHECK_THROWS(raw_bytes(a0, 1));
|
||||
CHECK_THROWS(raw_index_bytes(a0, 0, 0));
|
||||
#endif
|
||||
|
||||
CHECK(raw_bytes(b0, 0) == buf);
|
||||
CHECK(raw_bytes(bp, 0) == buf);
|
||||
|
|
|
@ -202,6 +202,11 @@ typedef upx_int64_t upx_off_t;
|
|||
# undef __unix__
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_DUP) && (HAVE_DUP + 0 == 0)
|
||||
# undef dup
|
||||
# define dup(x) (-1)
|
||||
#endif
|
||||
|
||||
#ifndef STDIN_FILENO
|
||||
# define STDIN_FILENO (fileno(stdin))
|
||||
#endif
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
**************************************************************************/
|
||||
|
||||
/*static*/ void FileBase::chmod(const char *name, int mode) {
|
||||
#if (HAVE_CHMOD)
|
||||
#if HAVE_CHMOD
|
||||
if (::chmod(name, mode) != 0)
|
||||
throwIOException(name, errno);
|
||||
#else
|
||||
|
|
|
@ -799,12 +799,12 @@ void ElfLinkerPpc32::relocate1(const Relocation *rel, byte *location, upx_uint64
|
|||
// Note that original (*location).displ is ignored.
|
||||
if (strcmp(type, "24") == 0) {
|
||||
if (3 & value)
|
||||
internal_error("unaligned word diplacement");
|
||||
internal_error("unaligned word displacement");
|
||||
// FIXME: displacement overflow?
|
||||
set_be32(location, (0xfc000003 & get_be32(location)) + (0x03fffffc & value));
|
||||
} else if (strcmp(type, "14") == 0) {
|
||||
if (3 & value)
|
||||
internal_error("unaligned word diplacement");
|
||||
internal_error("unaligned word displacement");
|
||||
// FIXME: displacement overflow?
|
||||
set_be32(location, (0xffff0003 & get_be32(location)) + (0x0000fffc & value));
|
||||
} else
|
||||
|
|
|
@ -566,8 +566,7 @@ unsigned Packer::getRandomId() const {
|
|||
int fd = open("/dev/urandom", O_RDONLY | O_BINARY);
|
||||
if (fd < 0)
|
||||
fd = open("/dev/random", O_RDONLY | O_BINARY);
|
||||
if (fd >= 0)
|
||||
{
|
||||
if (fd >= 0) {
|
||||
if (read(fd, &id, 4) != 4)
|
||||
id = 0;
|
||||
close(fd);
|
||||
|
@ -583,7 +582,7 @@ unsigned Packer::getRandomId() const {
|
|||
id ^= (unsigned) tv.tv_sec;
|
||||
id ^= ((unsigned) tv.tv_usec) << 12; // shift into high-bits
|
||||
#endif
|
||||
#if (HAVE_GETPID)
|
||||
#if HAVE_GETPID
|
||||
id ^= (unsigned) getpid();
|
||||
#endif
|
||||
id ^= (unsigned) fi->st.st_ino;
|
||||
|
|
|
@ -145,7 +145,7 @@ unsigned Packer::unoptimizeReloc(SPAN_S(const byte) & in, MemBuffer &out, SPAN_P
|
|||
}
|
||||
}
|
||||
in = fix + 1; // advance
|
||||
assert(relocnum == ptr_udiff_bytes(relocs, out) / 4);
|
||||
assert(relocnum == ptr_udiff_bytes(relocs, raw_bytes(out, 0)) / 4);
|
||||
return relocnum;
|
||||
}
|
||||
|
||||
|
|
|
@ -124,9 +124,13 @@ inline typename MemBufferBase<T>::pointer raw_index_bytes(const MemBufferBase<T>
|
|||
typename std::enable_if<std::is_same<A, B>::value, RType>::type
|
||||
#define C MemBufferBase
|
||||
#define XSPAN_FWD_C_IS_MEMBUFFER 1
|
||||
#if WITH_XSPAN >= 1
|
||||
#define D XSPAN_NS(Ptr)
|
||||
#endif
|
||||
#include "xspan_fwd.h"
|
||||
#undef XSPAN_FWD_C_IS_MEMBUFFER
|
||||
#undef C
|
||||
#undef D
|
||||
#undef XSPAN_REQUIRES_CONVERTIBLE_ANY_DIRECTION
|
||||
|
||||
/*************************************************************************
|
||||
|
|
|
@ -680,7 +680,7 @@ bool file_exists(const char *name) {
|
|||
return true;
|
||||
|
||||
/* return true if we can lstat it */
|
||||
#if (HAVE_LSTAT)
|
||||
#if HAVE_LSTAT
|
||||
// mem_clear(&st);
|
||||
r = lstat(name, &st);
|
||||
if (r != -1)
|
||||
|
|
|
@ -224,8 +224,12 @@ XSPAN_NAMESPACE_END
|
|||
#if 1
|
||||
|
||||
#define C XSPAN_NS(Ptr)
|
||||
template <class T>
|
||||
class MemBufferBase;
|
||||
#define D MemBufferBase
|
||||
#include "xspan_fwd.h"
|
||||
#undef C
|
||||
#undef D
|
||||
|
||||
#endif
|
||||
|
||||
|
|
24
src/work.cpp
24
src/work.cpp
|
@ -40,7 +40,7 @@
|
|||
#define USE_FTIME 1
|
||||
#elif ((ACC_OS_WIN32 || ACC_OS_WIN64) && (ACC_CC_INTELC || ACC_CC_MSC))
|
||||
#define USE__FUTIME 1
|
||||
#elif (HAVE_UTIME)
|
||||
#elif HAVE_UTIME
|
||||
#define USE_UTIME 1
|
||||
#endif
|
||||
|
||||
|
@ -62,7 +62,7 @@ void do_one_file(const char *iname, char *oname) {
|
|||
int r;
|
||||
struct stat st;
|
||||
mem_clear(&st);
|
||||
#if (HAVE_LSTAT)
|
||||
#if HAVE_LSTAT
|
||||
r = lstat(iname, &st);
|
||||
#else
|
||||
r = stat(iname, &st);
|
||||
|
@ -104,7 +104,7 @@ void do_one_file(const char *iname, char *oname) {
|
|||
fi.st = st;
|
||||
fi.sopen(iname, O_RDONLY | O_BINARY, SH_DENYWR);
|
||||
|
||||
#if (USE_FTIME)
|
||||
#if USE_FTIME
|
||||
struct ftime fi_ftime;
|
||||
mem_clear(&fi_ftime);
|
||||
if (opt->preserve_timestamp) {
|
||||
|
@ -124,7 +124,7 @@ void do_one_file(const char *iname, char *oname) {
|
|||
if (opt->output_name) {
|
||||
strcpy(tname, opt->output_name);
|
||||
if (opt->force_overwrite || opt->force >= 2) {
|
||||
#if (HAVE_CHMOD)
|
||||
#if HAVE_CHMOD
|
||||
r = chmod(tname, 0777);
|
||||
IGNORE_ERROR(r);
|
||||
#endif
|
||||
|
@ -173,10 +173,10 @@ void do_one_file(const char *iname, char *oname) {
|
|||
|
||||
// copy time stamp
|
||||
if (oname[0] && opt->preserve_timestamp && fo.isOpen()) {
|
||||
#if (USE_FTIME)
|
||||
#if USE_FTIME
|
||||
r = setftime(fo.getFd(), &fi_ftime);
|
||||
IGNORE_ERROR(r);
|
||||
#elif (USE__FUTIME)
|
||||
#elif USE__FUTIME
|
||||
struct _utimbuf u;
|
||||
u.actime = st.st_atime;
|
||||
u.modtime = st.st_mtime;
|
||||
|
@ -197,7 +197,7 @@ void do_one_file(const char *iname, char *oname) {
|
|||
throwIOException("could not create a backup file name");
|
||||
FileBase::rename(iname, bakname);
|
||||
} else {
|
||||
#if (HAVE_CHMOD)
|
||||
#if HAVE_CHMOD
|
||||
r = chmod(iname, 0777);
|
||||
IGNORE_ERROR(r);
|
||||
#endif
|
||||
|
@ -211,7 +211,7 @@ void do_one_file(const char *iname, char *oname) {
|
|||
oname[0] = 0; // done with oname
|
||||
const char *name = opt->output_name ? opt->output_name : iname;
|
||||
UNUSED(name);
|
||||
#if (USE_UTIME)
|
||||
#if USE_UTIME
|
||||
// copy time stamp
|
||||
if (opt->preserve_timestamp) {
|
||||
struct utimbuf u;
|
||||
|
@ -221,21 +221,21 @@ void do_one_file(const char *iname, char *oname) {
|
|||
IGNORE_ERROR(r);
|
||||
}
|
||||
#endif
|
||||
#if (HAVE_CHOWN)
|
||||
#if HAVE_CHOWN
|
||||
// copy the group ownership
|
||||
if (opt->preserve_ownership) {
|
||||
r = chown(name, -1, st.st_gid);
|
||||
IGNORE_ERROR(r);
|
||||
}
|
||||
#endif
|
||||
#if (HAVE_CHMOD)
|
||||
#if HAVE_CHMOD
|
||||
// copy permissions
|
||||
if (opt->preserve_mode) {
|
||||
r = chmod(name, st.st_mode);
|
||||
IGNORE_ERROR(r);
|
||||
}
|
||||
#endif
|
||||
#if (HAVE_CHOWN)
|
||||
#if HAVE_CHOWN
|
||||
// copy the user ownership
|
||||
if (opt->preserve_ownership) {
|
||||
r = chown(name, st.st_uid, -1);
|
||||
|
@ -253,7 +253,7 @@ void do_one_file(const char *iname, char *oname) {
|
|||
|
||||
static void unlink_ofile(char *oname) {
|
||||
if (oname && oname[0]) {
|
||||
#if (HAVE_CHMOD)
|
||||
#if HAVE_CHMOD
|
||||
int r;
|
||||
r = chmod(oname, 0777);
|
||||
IGNORE_ERROR(r);
|
||||
|
|
Loading…
Reference in New Issue