#870·upx

How to preserve a specific named section

Author: jamosdevCreated Jan 29, 2025Updated Jun 19, 2026
Labelsenhancementos:Windows

This issue tracker is ONLY used for requesting sensible features. Please use stackoverflow for supporting issues.

What's the problem (or question)?

I searched for how to preserve 1 specific section, i found that UPX handles overlays and keep windows resources, but this is not an overlay or a windows resource this is a data->code compiled into its own named section, and done same way for windows, linux, and macos so windows resource won't be an alternative. i.e.

__declspec(allocate("RAR")) static char data[1024*1024*10] = { 0 };

or

const char data[1024*1024*10] __attribute__((section("RAR"), used)) = { 0 };

here named "RAR" but could be anything (want to specify the name on the command line to UPX)

What should have happened?

upx will be told the name of a section to preserve, then the output exe so the UPX stub I suppose will also have this section with the same name and the same data in original form, not compressed (it is already pre-compressed by the application)

Do you have an idea for a solution?

the attached data can be 300mb data and the exe size minus the data would be about 38mb, so copying temporary files will make a slower startup time. when the program runs it opens itself from argv0 and parses the exe headers looking for a section with a specific name. if the upx compressed exe can have a section added to it based on the command line parameter, and then size and data populate it from the to-be-compressed exe into the output file, it should work.

the named section contains a pre-compressed archive with all application datafiles in it (zstandard with built-in custom dictionary)

How can we reproduce the issue?

  1. make a program with a custom named section with lots of data in it
  2. when the program runs it opens itself, walks its elf/pe/macho headers, finds the named section
  3. then it prints the data
  4. compress it with upx

Please tell us details about your environment.

upx 4.2.4 NRV data compression library 0.84 UCL data compression library 1.03 zlib data compression library 1.3.1.1-motley LZMA SDK version 4.43

host and target are the same as each other

Windows 11, MacOS 15, Ubuntu 22.04.5 windows x64/arm64, mac arm64, linux x64