termux-packages/packages/elfutils/ldgeneric.c.patch

61 lines
1.8 KiB
Diff

diff -u -r ../elfutils-0.166/src/ldgeneric.c ./src/ldgeneric.c
--- ../elfutils-0.166/src/ldgeneric.c 2015-08-21 08:22:37.000000000 -0400
+++ ./src/ldgeneric.c 2016-05-04 15:20:09.029651147 -0400
@@ -1747,7 +1747,13 @@
/* The content of the file is available in memory. Read the
memory region as a stream. */
+#ifdef __ANDROID__
+ ldin = tmpfile();
+ fwrite(content, 1, contentsize, ldin);
+ rewind(ldin);
+#else
ldin = fmemopen (content, contentsize, "r");
+#endif
}
/* No need for locking. */
@@ -2631,9 +2637,9 @@
/* Callback function registered with on_exit to make sure the temporary
files gets removed if something goes wrong. */
static void
-remove_tempfile (int status, void *arg)
+remove_tempfile ()
{
- if (status != 0 && ld_state.tempfname != NULL)
+ if (ld_state.tempfname != NULL)
unlink (ld_state.tempfname);
}
@@ -2680,7 +2686,7 @@
/* Make sure we remove the temporary file in case something goes
wrong. */
- on_exit (remove_tempfile, NULL);
+ atexit (remove_tempfile);
/* Create the ELF file data for the output file. */
Elf *elf = ld_state.outelf = elf_begin (fd,
@@ -3352,6 +3358,7 @@
struct id_list search;
struct id_list *verp;
bool result = ld_state.default_bind_local;
+ size_t substr_len;
if (XELF_ST_BIND (sym->st_info) == STB_LOCAL || sym->st_shndx == SHN_UNDEF)
/* We don't have to do anything to local symbols here. */
@@ -3367,7 +3374,12 @@
version = strchr (str, VER_CHR);
if (version != NULL)
{
- search.id = strndupa (str, version - str);
+ substr_len = version - str;
+ char* tmp = alloca(substr_len+1);
+ strncpy(tmp, str, substr_len);
+ tmp[substr_len] = 0;
+ search.id = tmp;
+
if (*++version == VER_CHR)
/* Skip the second '@' signaling a default definition. */
++version;