Skip to content

Instantly share code, notes, and snippets.

@agrif
Created May 15, 2025 12:58
Show Gist options
  • Save agrif/e81c5227685601d58e23f29d2fc894d7 to your computer and use it in GitHub Desktop.
Save agrif/e81c5227685601d58e23f29d2fc894d7 to your computer and use it in GitHub Desktop.
diff -ur -x build -x prefix binutils-with-gold-2.44/bfd/opncls.c binutils-wasi/bfd/opncls.c
--- binutils-with-gold-2.44/bfd/opncls.c 2025-02-01 19:00:00.000000000 -0500
+++ binutils-wasi/bfd/opncls.c 2025-05-15 08:13:04.975771488 -0400
@@ -870,9 +870,9 @@
which run tests with "ld [...] -o /dev/null". */
&& S_ISREG(buf.st_mode))
{
- unsigned int mask = umask (0);
+ unsigned int mask = 022;/*umask (0);*/
- umask (mask);
+ //umask (mask);
chmod (bfd_get_filename (abfd),
(0777
& (buf.st_mode | ((S_IXUSR | S_IXGRP | S_IXOTH) &~ mask))));
diff -ur -x build -x prefix binutils-with-gold-2.44/bfd/plugin.c binutils-wasi/bfd/plugin.c
--- binutils-with-gold-2.44/bfd/plugin.c 2025-02-01 19:00:00.000000000 -0500
+++ binutils-wasi/bfd/plugin.c 2025-05-15 08:13:38.828949638 -0400
@@ -471,7 +471,7 @@
will be closed by _bfd_archive_close_and_cleanup. */
if (abfd->archive_plugin_fd_open_count == 0)
{
- abfd->archive_plugin_fd = dup (fd);
+ abfd->archive_plugin_fd = -1;/*dup (fd);*/
close (fd);
}
}
diff -ur -x build -x prefix binutils-with-gold-2.44/binutils/ar.c binutils-wasi/binutils/ar.c
--- binutils-with-gold-2.44/binutils/ar.c 2025-02-01 19:00:00.000000000 -0500
+++ binutils-wasi/binutils/ar.c 2025-05-15 08:34:48.021877833 -0400
@@ -1305,7 +1305,7 @@
if (!bfd_set_archive_head (obfd, contents_head))
bfd_fatal (old_name);
- tmpfd = dup (tmpfd);
+ tmpfd = -1;/*dup (tmpfd);*/
if (!bfd_close (obfd))
bfd_fatal (old_name);
diff -ur -x build -x prefix binutils-with-gold-2.44/binutils/arsup.c binutils-wasi/binutils/arsup.c
--- binutils-with-gold-2.44/binutils/arsup.c 2025-02-01 19:00:00.000000000 -0500
+++ binutils-wasi/binutils/arsup.c 2025-05-15 08:35:10.902683800 -0400
@@ -352,7 +352,7 @@
if (deterministic > 0)
obfd->flags |= BFD_DETERMINISTIC_OUTPUT;
- temp_fd = dup (temp_fd);
+ temp_fd = -1; /*dup (temp_fd);*/
bfd_close (obfd);
if (stat (real_name, &target_stat) != 0)
diff -ur -x build -x prefix binutils-with-gold-2.44/binutils/bucomm.c binutils-wasi/binutils/bucomm.c
--- binutils-with-gold-2.44/binutils/bucomm.c 2025-02-01 19:00:00.000000000 -0500
+++ binutils-wasi/binutils/bucomm.c 2025-05-15 08:34:19.088858267 -0400
@@ -546,7 +546,7 @@
#ifdef HAVE_MKSTEMP
fd = mkstemp (tmpname);
#else
- tmpname = mktemp (tmpname);
+ tmpname = 0;/*mktemp (tmpname);*/
if (tmpname == NULL)
fd = -1;
else
@@ -574,7 +574,7 @@
#ifdef HAVE_MKDTEMP
ret = mkdtemp (tmpname);
#else
- ret = mktemp (tmpname);
+ ret = 0; /*mktemp (tmpname);*/
#if defined (_WIN32) && !defined (__CYGWIN32__)
if (mkdir (tmpname) != 0)
ret = NULL;
diff -ur -x build -x prefix binutils-with-gold-2.44/binutils/objcopy.c binutils-wasi/binutils/objcopy.c
--- binutils-with-gold-2.44/binutils/objcopy.c 2025-02-01 19:00:00.000000000 -0500
+++ binutils-wasi/binutils/objcopy.c 2025-05-15 08:35:42.699803439 -0400
@@ -5031,7 +5031,7 @@
{
tmpname = make_tempname (argv[i], &tmpfd);
if (tmpfd >= 0)
- copyfd = dup (tmpfd);
+ copyfd = -1; /*dup (tmpfd);*/
}
else
tmpname = output_file;
@@ -6133,7 +6133,7 @@
{
tmpname = make_tempname (input_filename, &tmpfd);
if (tmpfd >= 0)
- copyfd = dup (tmpfd);
+ copyfd = -1; /*dup (tmpfd);*/
}
else
tmpname = output_filename;
diff -ur -x build -x prefix binutils-with-gold-2.44/gas/messages.c binutils-wasi/gas/messages.c
--- binutils-with-gold-2.44/gas/messages.c 2025-02-01 19:00:00.000000000 -0500
+++ binutils-wasi/gas/messages.c 2025-05-15 08:14:48.635378776 -0400
@@ -24,7 +24,7 @@
/* If the system doesn't provide strsignal, we get it defined in
libiberty but no declaration is supplied. Because, reasons. */
#if !defined (HAVE_STRSIGNAL) && !defined (strsignal)
-extern const char *strsignal (int);
+extern char *strsignal (int);
#endif
static void identify (const char *);
diff -ur -x build -x prefix binutils-with-gold-2.44/ld/ldlang.c binutils-wasi/ld/ldlang.c
--- binutils-with-gold-2.44/ld/ldlang.c 2025-02-01 19:00:00.000000000 -0500
+++ binutils-wasi/ld/ldlang.c 2025-05-15 08:36:31.977537660 -0400
@@ -10589,7 +10589,7 @@
#ifdef HAVE_MKSTEMP
fd = mkstemp (tmpname);
#else
- tmpname = mktemp (tmpname);
+ tmpname = 0; /*mktemp (tmpname);*/
if (tmpname == NULL)
return NULL;
fd = open (tmpname, O_RDWR | O_CREAT | O_EXCL, 0600);
diff -ur -x build -x prefix binutils-with-gold-2.44/libctf/ctf-decls.h binutils-wasi/libctf/ctf-decls.h
--- binutils-with-gold-2.44/libctf/ctf-decls.h 2025-02-01 19:00:00.000000000 -0500
+++ binutils-wasi/libctf/ctf-decls.h 2025-05-15 08:32:20.932689571 -0400
@@ -27,6 +27,7 @@
#include "libiberty.h"
#if HAVE_QSORT_R_ARG_LAST
+void qsort_r (void *, size_t, size_t, int (*)(const void *, const void *, void *), void *);
static inline void
ctf_qsort_r (void *base, size_t nmemb, size_t size,
int (*compar)(const void *, const void *, void *),
diff -ur -x build -x prefix binutils-with-gold-2.44/libctf/ctf-link.c binutils-wasi/libctf/ctf-link.c
--- binutils-with-gold-2.44/libctf/ctf-link.c 2025-02-01 19:00:00.000000000 -0500
+++ binutils-wasi/libctf/ctf-link.c 2025-05-15 08:38:08.568934044 -0400
@@ -2000,7 +2000,7 @@
memmove (&(arg.files[1]), arg.files, sizeof (ctf_dict_t *) * (arg.i));
arg.files[0] = fp;
- if ((f = tmpfile ()) == NULL)
+ if ((f = 0/*tmpfile ()*/) == NULL)
{
errloc = "tempfile creation";
goto err_no;
diff -ur -x build -x prefix binutils-with-gold-2.44/libctf/ctf-open-bfd.c binutils-wasi/libctf/ctf-open-bfd.c
--- binutils-with-gold-2.44/libctf/ctf-open-bfd.c 2025-02-01 19:00:00.000000000 -0500
+++ binutils-wasi/libctf/ctf-open-bfd.c 2025-05-15 08:32:51.513769307 -0400
@@ -313,7 +313,7 @@
/* Attempt to open the file with BFD. We must dup the fd first, since bfd
takes ownership of the passed fd. */
- if ((nfd = dup (fd)) < 0)
+ if ((nfd = -1/*dup (fd)*/) < 0)
return (ctf_set_open_errno (errp, errno));
if ((abfd = bfd_fdopenr (filename, target, nfd)) == NULL)
diff -ur -x build -x prefix binutils-with-gold-2.44/libiberty/choose-temp.c binutils-wasi/libiberty/choose-temp.c
--- binutils-with-gold-2.44/libiberty/choose-temp.c 2025-02-01 19:00:00.000000000 -0500
+++ binutils-wasi/libiberty/choose-temp.c 2025-05-15 07:58:32.169367710 -0400
@@ -68,7 +68,7 @@
strcpy (temp_filename, base);
strcpy (temp_filename + len, TEMP_FILE);
- if (mktemp (temp_filename) == 0)
+ if (0 == 0)
abort ();
return temp_filename;
}
diff -ur -x build -x prefix binutils-with-gold-2.44/libiberty/clock.c binutils-wasi/libiberty/clock.c
--- binutils-with-gold-2.44/libiberty/clock.c 2025-02-01 19:00:00.000000000 -0500
+++ binutils-wasi/libiberty/clock.c 2025-05-15 08:46:02.421557504 -0400
@@ -66,7 +66,7 @@
/* FIXME: should be able to declare as clock_t. */
-long
+int64_t
clock (void)
{
#ifdef HAVE_GETRUSAGE
diff -ur -x build -x prefix binutils-with-gold-2.44/libiberty/pex-unix.c binutils-wasi/libiberty/pex-unix.c
--- binutils-with-gold-2.44/libiberty/pex-unix.c 2025-02-01 19:00:00.000000000 -0500
+++ binutils-wasi/libiberty/pex-unix.c 2025-05-15 08:10:04.817501057 -0400
@@ -256,7 +256,7 @@
#endif
}
- cpid = wait (status);
+ cpid = -1; /*wait (status);*/
#ifdef HAVE_GETRUSAGE
if (time != NULL && cpid >= 0)
@@ -758,7 +758,7 @@
if (pipe2 ((int *)pipes, O_CLOEXEC))
do_pipe = 0;
#else
- if (pipe ((int *)pipes))
+ if (-1/*pipe ((int *)pipes)*/)
do_pipe = 0;
else
{
@@ -787,7 +787,7 @@
for (retries = 0; retries < 4; ++retries)
{
- pid = vfork ();
+ pid = -1; /*vfork ();*/
if (pid >= 0)
break;
sleep (sleep_interval);
@@ -816,21 +816,21 @@
close (pipes[0]);
if (!failed.fn && in != STDIN_FILE_NO)
{
- if (dup2 (in, STDIN_FILE_NO) < 0)
+ if (-1 /*dup2 (in, STDIN_FILE_NO)*/ < 0)
failed.fn = "dup2", failed.err = errno;
else if (close (in) < 0)
failed.fn = "close", failed.err = errno;
}
if (!failed.fn && out != STDOUT_FILE_NO)
{
- if (dup2 (out, STDOUT_FILE_NO) < 0)
+ if (-1 /*dup2 (out, STDOUT_FILE_NO)*/ < 0)
failed.fn = "dup2", failed.err = errno;
else if (close (out) < 0)
failed.fn = "close", failed.err = errno;
}
if (!failed.fn && errdes != STDERR_FILE_NO)
{
- if (dup2 (errdes, STDERR_FILE_NO) < 0)
+ if (-1 /*dup2 (errdes, STDERR_FILE_NO)*/ < 0)
failed.fn = "dup2", failed.err = errno;
else if (close (errdes) < 0)
failed.fn = "close", failed.err = errno;
@@ -842,7 +842,7 @@
}
if (!failed.fn && (flags & PEX_STDERR_TO_STDOUT) != 0)
{
- if (dup2 (STDOUT_FILE_NO, STDERR_FILE_NO) < 0)
+ if (-1/*dup2 (STDOUT_FILE_NO, STDERR_FILE_NO)*/ < 0)
failed.fn = "dup2", failed.err = errno;
}
if (!failed.fn)
@@ -854,12 +854,12 @@
environ = (char**) env;
if ((flags & PEX_SEARCH) != 0)
{
- execvp (executable, to_ptr32 (argv));
+ //execvp (executable, to_ptr32 (argv));
failed.fn = "execvp", failed.err = errno;
}
else
{
- execv (executable, to_ptr32 (argv));
+ //execv (executable, to_ptr32 (argv));
failed.fn = "execv", failed.err = errno;
}
}
@@ -943,8 +943,8 @@
{
/* If we are cleaning up when the caller didn't retrieve process
status for some reason, encourage the process to go away. */
- if (done)
- kill (pid, SIGTERM);
+ //if (done)
+ // kill (pid, SIGTERM);
if (pex_wait (obj, pid, status, time) < 0)
{
@@ -962,7 +962,7 @@
pex_unix_pipe (struct pex_obj *obj ATTRIBUTE_UNUSED, int *p,
int binary ATTRIBUTE_UNUSED)
{
- return pipe (p);
+ return -1;//pipe (p);
}
/* Get a FILE pointer to read from a file descriptor. */
diff -ur -x build -x prefix binutils-with-gold-2.44/libiberty/strsignal.c binutils-wasi/libiberty/strsignal.c
--- binutils-with-gold-2.44/libiberty/strsignal.c 2025-02-01 19:00:00.000000000 -0500
+++ binutils-wasi/libiberty/strsignal.c 2025-05-15 08:10:44.338876746 -0400
@@ -551,7 +551,7 @@
#ifndef HAVE_PSIGNAL
void
-psignal (int signo, char *message)
+psignal (int signo, const char *message)
{
if (signal_names == NULL)
{
diff -ur -x build -x prefix binutils-with-gold-2.44/libiberty/waitpid.c binutils-wasi/libiberty/waitpid.c
--- binutils-with-gold-2.44/libiberty/waitpid.c 2025-02-01 19:00:00.000000000 -0500
+++ binutils-wasi/libiberty/waitpid.c 2025-05-15 08:11:07.247674121 -0400
@@ -33,7 +33,7 @@
{
for (;;)
{
- int wpid = wait(stat_loc);
+ int wpid = -1;/*wait(stat_loc);*/
if (wpid == pid || wpid == -1)
return wpid;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment