src: fix building under freebsd; updates
This commit is contained in:
+10
@@ -32,6 +32,16 @@
|
||||
// NE - Native Endianness (aka host endianness)
|
||||
// TE - Target Endianness (not used here, see various packers)
|
||||
|
||||
#if 1
|
||||
// some platforms may provide their own system bswapXX() functions, so rename
|
||||
#undef bswap16
|
||||
#undef bswap32
|
||||
#undef bswap64
|
||||
#define bswap16 upx_bswap16
|
||||
#define bswap32 upx_bswap32
|
||||
#define bswap64 upx_bswap64
|
||||
#endif
|
||||
|
||||
/*************************************************************************
|
||||
// core - NE
|
||||
**************************************************************************/
|
||||
|
||||
+3
-3
@@ -325,9 +325,9 @@ void PackDjgpp2::pack(OutputFile *fo) {
|
||||
OutputFile::dump(opt->debug.dump_stub_loader, loader, lsize);
|
||||
fo->write(obuf, data->size);
|
||||
#if 0
|
||||
printf("%-13s: coff hdr : %8ld bytes\n", getName(), (long) sizeof(coff_hdr));
|
||||
printf("%-13s: loader : %8ld bytes\n", getName(), (long) lsize);
|
||||
printf("%-13s: compressed : %8ld bytes\n", getName(), (long) data->size);
|
||||
printf("%-13s: coff hdr : %8d bytes\n", getName(), (int) sizeof(coff_hdr));
|
||||
printf("%-13s: loader : %8d bytes\n", getName(), (int) lsize);
|
||||
printf("%-13s: compressed : %8d bytes\n", getName(), (int) data->size);
|
||||
#endif
|
||||
|
||||
// verify
|
||||
|
||||
+26
-15
@@ -579,22 +579,33 @@ void PackPs1::pack(OutputFile *fo) {
|
||||
throwNotCompressible();
|
||||
|
||||
#if 0
|
||||
printf("%-13s: uncompressed : %8ld bytes\n", getName(), (long) ph.u_len);
|
||||
printf("%-13s: compressed : %8ld bytes\n", getName(), (long) ph.c_len);
|
||||
printf("%-13s: decompressor : %8ld bytes\n", getName(), (long) lsize - h_len - pad_code);
|
||||
printf("%-13s: header comp : %8ld bytes\n", getName(), (long) sz_cbh);
|
||||
printf("%-13s: overlap : %8ld bytes\n", getName(), (long) overlap);
|
||||
printf("%-13s: load address : %08X bytes\n", getName(), (unsigned int) oh.tx_ptr);
|
||||
printf("%-13s: code entry : %08X bytes\n", getName(), (unsigned int) oh.epc);
|
||||
printf("%-13s: bbs start : %08X bytes\n", getName(), (unsigned int) bss_start);
|
||||
printf("%-13s: bbs end : %08X bytes\n", getName(), (unsigned int) bss_end);
|
||||
printf("%-13s: eof in mem IF : %08X bytes\n", getName(), (unsigned int) ih.tx_ptr + ih.tx_len);
|
||||
printf("%-13s: eof in mem OF : %08X bytes\n", getName(), (unsigned int) oh.tx_ptr + oh.tx_len);
|
||||
printf("%-13s: uncompressed : %8d bytes\n", getName(), (int) ph.u_len);
|
||||
printf("%-13s: compressed : %8d bytes\n", getName(), (int) ph.c_len);
|
||||
printf("%-13s: decompressor : %8d bytes\n", getName(), (int) lsize - h_len - pad_code);
|
||||
printf("%-13s: header comp : %8d bytes\n", getName(), (int) sz_cbh);
|
||||
printf("%-13s: overlap : %8d bytes\n", getName(), (int) overlap);
|
||||
printf("%-13s: load address : %08X bytes\n", getName(), (unsigned) oh.tx_ptr);
|
||||
printf("%-13s: code entry : %08X bytes\n", getName(), (unsigned) oh.epc);
|
||||
printf("%-13s: bbs start : %08X bytes\n", getName(), (unsigned) bss_start);
|
||||
printf("%-13s: bbs end : %08X bytes\n", getName(), (unsigned) bss_end);
|
||||
printf("%-13s: eof in mem IF : %08X bytes\n", getName(), (unsigned) ih.tx_ptr + ih.tx_len);
|
||||
printf("%-13s: eof in mem OF : %08X bytes\n", getName(), (unsigned) oh.tx_ptr + oh.tx_len);
|
||||
byte i = 0;
|
||||
if (isCon) { if (foundBss) i = 1; }
|
||||
else { i = 2; if (M_IS_LZMA(ph.method)) { if (!foundBss) i = 3; else i = 4; } }
|
||||
const char *loader_method[] = { "con/stack", "con/bss", "cdb", "cdb/stack", "cdb/bss" };
|
||||
char method_name[32+1]; set_method_name(method_name, sizeof(method_name), ph.method, ph.level);
|
||||
if (isCon) {
|
||||
if (foundBss)
|
||||
i = 1;
|
||||
} else {
|
||||
i = 2;
|
||||
if (M_IS_LZMA(ph.method)) {
|
||||
if (!foundBss)
|
||||
i = 3;
|
||||
else
|
||||
i = 4;
|
||||
}
|
||||
}
|
||||
const char *loader_method[] = {"con/stack", "con/bss", "cdb", "cdb/stack", "cdb/bss"};
|
||||
char method_name[32 + 1];
|
||||
set_method_name(method_name, sizeof(method_name), ph.method, ph.level);
|
||||
printf("%-13s: methods : %s, %s\n", getName(), method_name, loader_method[i]);
|
||||
#endif
|
||||
}
|
||||
|
||||
+1
-1
@@ -99,7 +99,7 @@ protected:
|
||||
unsigned clear_dirty_stack_len;
|
||||
unsigned copy_to_stack_len;
|
||||
|
||||
void reset() noexcept { memset(this, 0, sizeof(*this)); }
|
||||
void reset() noexcept { mem_clear(this); }
|
||||
};
|
||||
LinkerSymbols symbols;
|
||||
};
|
||||
|
||||
+20
-23
@@ -551,18 +551,16 @@ void PeFile64::processRelocs() // pass1
|
||||
// deliberately corrupt. Sometimes it is even tuned to cause us trouble!
|
||||
// Use an extra check to avoid AccessViolation (SIGSEGV) when appending
|
||||
// the relocs into one array.
|
||||
if ((4 * relocnum + 8192) < (sorelocs + 4*(2 + xcounts[2] + xcounts[1])))
|
||||
if ((4 * relocnum + 8192) < (sorelocs + 4 * (2 + xcounts[2] + xcounts[1])))
|
||||
throwCantUnpack("Invalid relocs");
|
||||
|
||||
// append relocs type "LOW" then "HIGH"
|
||||
for (ic = 2; ic ; ic--)
|
||||
{
|
||||
memcpy(orelocs + sorelocs,fix[ic],4 * xcounts[ic]);
|
||||
for (ic = 2; ic; ic--) {
|
||||
memcpy(orelocs + sorelocs, fix[ic], 4 * xcounts[ic]);
|
||||
sorelocs += 4 * xcounts[ic];
|
||||
|
||||
set_le32(orelocs + sorelocs,0);
|
||||
if (xcounts[ic])
|
||||
{
|
||||
set_le32(orelocs + sorelocs, 0);
|
||||
if (xcounts[ic]) {
|
||||
sorelocs += 4;
|
||||
big_relocs |= 2 * ic;
|
||||
}
|
||||
@@ -1933,8 +1931,8 @@ unsigned PeFile::virta2objnum(unsigned addr, SPAN_0(pe_section_t) sect, unsigned
|
||||
unsigned PeFile::tryremove(unsigned vaddr, unsigned objs) {
|
||||
unsigned ic = virta2objnum(vaddr, isection, objs);
|
||||
if (ic && ic == objs - 1) {
|
||||
NO_fprintf(stderr, "removed section: %d size: %lx\n", ic, (long) isection[ic].size);
|
||||
info("removed section: %d size: 0x%lx", ic, (long) isection[ic].size);
|
||||
NO_fprintf(stderr, "removed section: %d size: 0x%x\n", ic, (int) isection[ic].size);
|
||||
info("removed section: %d size: 0x%x", ic, (int) isection[ic].size);
|
||||
objs--;
|
||||
}
|
||||
return objs;
|
||||
@@ -2322,6 +2320,7 @@ void PeFile::pack0(OutputFile *fo, ht &ih, ht &oh, unsigned subsystem_mask,
|
||||
const unsigned oobjs = last_section_rsrc_only ? 4 : has_ncsection ? 3 : 2;
|
||||
////pe_section_t osection[oobjs];
|
||||
pe_section_t osection[4];
|
||||
memset(osection, 0, sizeof(osection));
|
||||
// section 0 : bss
|
||||
// 1 : [ident + header] + packed_data + unpacker + tls + loadconf
|
||||
// 2 : not compressed data
|
||||
@@ -2361,7 +2360,6 @@ void PeFile::pack0(OutputFile *fo, ht &ih, ht &oh, unsigned subsystem_mask,
|
||||
// new PE header
|
||||
memcpy(&oh, &ih, sizeof(oh));
|
||||
oh.filealign = oh_filealign; // identsplit depends on this
|
||||
memset(osection, 0, sizeof(osection));
|
||||
|
||||
oh.entry = upxsection;
|
||||
oh.objects = oobjs;
|
||||
@@ -2449,7 +2447,6 @@ void PeFile::pack0(OutputFile *fo, ht &ih, ht &oh, unsigned subsystem_mask,
|
||||
// too idiot to use the data directories... M$ suxx 4 ever!
|
||||
// ... even worse: exploder.exe in NiceTry also depends on this to
|
||||
// locate version info
|
||||
|
||||
strcpy(osection[2].name, !last_section_rsrc_only && soresources ? ".rsrc" : "UPX2");
|
||||
|
||||
osection[0].vaddr = rvamin;
|
||||
@@ -2556,18 +2553,18 @@ void PeFile::pack0(OutputFile *fo, ht &ih, ht &oh, unsigned subsystem_mask,
|
||||
}
|
||||
|
||||
#if 0
|
||||
printf("%-13s: program hdr : %8ld bytes\n", getName(), (long) sizeof(oh));
|
||||
printf("%-13s: sections : %8ld bytes\n", getName(), (long) sizeof(osection[0])*oobjs);
|
||||
printf("%-13s: ident : %8ld bytes\n", getName(), (long) identsize);
|
||||
printf("%-13s: compressed : %8ld bytes\n", getName(), (long) c_len);
|
||||
printf("%-13s: decompressor : %8ld bytes\n", getName(), (long) codesize);
|
||||
printf("%-13s: tls : %8ld bytes\n", getName(), (long) sotls);
|
||||
printf("%-13s: aligned_tls : %8ld bytes\n", getName(), (long) aligned_sotls);
|
||||
printf("%-13s: resources : %8ld bytes\n", getName(), (long) soresources);
|
||||
printf("%-13s: imports : %8ld bytes\n", getName(), (long) soimpdlls);
|
||||
printf("%-13s: exports : %8ld bytes\n", getName(), (long) soexport);
|
||||
printf("%-13s: relocs : %8ld bytes\n", getName(), (long) soxrelocs);
|
||||
printf("%-13s: loadconf : %8ld bytes\n", getName(), (long) soloadconf);
|
||||
printf("%-13s: program hdr : %8d bytes\n", getName(), (int) sizeof(oh));
|
||||
printf("%-13s: sections : %8d bytes\n", getName(), (int) sizeof(osection[0]) * oobjs);
|
||||
printf("%-13s: ident : %8d bytes\n", getName(), (int) identsize);
|
||||
printf("%-13s: compressed : %8d bytes\n", getName(), (int) c_len);
|
||||
printf("%-13s: decompressor : %8d bytes\n", getName(), (int) codesize);
|
||||
printf("%-13s: tls : %8d bytes\n", getName(), (int) sotls);
|
||||
printf("%-13s: aligned_tls : %8d bytes\n", getName(), (int) aligned_sotls);
|
||||
printf("%-13s: resources : %8d bytes\n", getName(), (int) soresources);
|
||||
printf("%-13s: imports : %8d bytes\n", getName(), (int) soimpdlls);
|
||||
printf("%-13s: exports : %8d bytes\n", getName(), (int) soexport);
|
||||
printf("%-13s: relocs : %8d bytes\n", getName(), (int) soxrelocs);
|
||||
printf("%-13s: loadconf : %8d bytes\n", getName(), (int) soloadconf);
|
||||
#endif
|
||||
|
||||
// verify
|
||||
|
||||
@@ -179,8 +179,14 @@ private:
|
||||
struct Stats {
|
||||
upx_std_atomic(upx_uint32_t) global_alloc_counter;
|
||||
upx_std_atomic(upx_uint32_t) global_dealloc_counter;
|
||||
#if WITH_THREADS
|
||||
// avoid link errors on some 32-bit platforms: undefined reference to __atomic_fetch_add_8
|
||||
upx_std_atomic(size_t) global_total_bytes; // stats may overflow on 32-bit systems
|
||||
upx_std_atomic(size_t) global_total_active_bytes;
|
||||
#else
|
||||
upx_std_atomic(upx_uint64_t) global_total_bytes;
|
||||
upx_std_atomic(upx_uint64_t) global_total_active_bytes;
|
||||
#endif
|
||||
};
|
||||
static Stats stats;
|
||||
#if DEBUG
|
||||
|
||||
Reference in New Issue
Block a user