Add support for symbol table in .com files

This change fixes minor bugs and adds a feature, which lets us store the
ELF symbol table, inside the ZIP directory. We use the path /zip/.symtab
which can be safely removed using a zip editing tool, to make the binary
smaller after compilation. This supplements the existing method of using
a separate .com.dbg file, which is still supported. The intent is people
don't always know that it's a good idea to download the debug file. It's
not great having someone's first experience be a crash report, that only
has numbers rather than symbols. This will help fix that!
This commit is contained in:
Justine Tunney 2022-03-23 06:31:55 -07:00
parent 393ca4be40
commit 23b72eb617
61 changed files with 963 additions and 510 deletions

View file

@ -17,6 +17,7 @@
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/calls/internal.h"
#include "libc/calls/strace.internal.h"
#include "libc/dce.h"
#include "libc/errno.h"
#include "libc/nt/winsock.h"
@ -50,19 +51,29 @@ static bool setsockopt_polyfill(int *optname) {
*/
int setsockopt(int fd, int level, int optname, const void *optval,
uint32_t optlen) {
if (!optval) return efault();
if (!level || !optname) return enoprotoopt(); /* our sysvconsts definition */
if (optname == -1) return 0; /* our sysvconsts definition */
if (!IsWindows()) {
int e, rc;
if (!optval) {
rc = efault();
} else if (!level || !optname) {
rc = enoprotoopt(); /* our sysvconsts definition */
} else if (optname == -1) {
rc = 0; /* our sysvconsts definition */
} else if (!IsWindows()) {
rc = -1;
e = errno;
do {
if (sys_setsockopt(fd, level, optname, optval, optlen) != -1) {
return 0;
errno = e;
rc = 0;
break;
}
} while (setsockopt_polyfill(&optname));
return -1;
} else if (__isfdkind(fd, kFdSocket)) {
return sys_setsockopt_nt(&g_fds.p[fd], level, optname, optval, optlen);
rc = sys_setsockopt_nt(&g_fds.p[fd], level, optname, optval, optlen);
} else {
return ebadf();
rc = ebadf();
}
STRACE("setsockopt(%d, %#x, %#x, %p, %'u) → %d% m", fd, level, optname,
optval, optlen, rc);
return rc;
}