mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-01-31 19:43:32 +00:00
8ff48201ca
This change takes an entirely new approach to the incremental linking of pkzip executables. The assets created by zipobj.com are now treated like debug data. After a .com.dbg is compiled, fixupobj.com should be run, so it can apply fixups to the offsets and move the zip directory to the end of the file. Since debug data doesn't get objcopy'd, a new tool has been introduced called zipcopy.com which should be run after objcopy whenever a .com file is created. This is all automated by the `cosmocc` toolchain which is rapidly becoming the new recommended approach. This change also introduces the new C23 checked arithmetic macros.
29 lines
610 B
C
29 lines
610 B
C
#include "libc/assert.h"
|
|
#include "libc/fmt/conv.h"
|
|
#include "libc/stdio/stdio.h"
|
|
|
|
/**
|
|
* Displays bytes as word, e.g.
|
|
*
|
|
* o//tool/word.com 6e c7 ff ff
|
|
* %d = -14482
|
|
* %ld = 4294952814
|
|
* %#x = 0xffffc76e
|
|
* %#lx = 0xffffc76e
|
|
*
|
|
*/
|
|
int main(int argc, char *argv[]) {
|
|
long x;
|
|
int i, k, b;
|
|
for (x = k = 0, i = 1; i < argc; ++i) {
|
|
b = strtol(argv[i], 0, 16);
|
|
assert(0 <= b && b <= 255);
|
|
x |= (unsigned long)b << k;
|
|
k += 8;
|
|
}
|
|
printf("%%d = %d\n"
|
|
"%%ld = %ld\n"
|
|
"%%#x = %#x\n"
|
|
"%%#lx = %#lx\n",
|
|
(int)x, x, (int)x, x);
|
|
}
|