chiark / gitweb /
libelf: Update to latest version
[termux-packages] / packages / libelf / ldgeneric.c.patch
1 diff -u -r ../elfutils-0.166/src/ldgeneric.c ./src/ldgeneric.c
2 --- ../elfutils-0.166/src/ldgeneric.c   2015-08-21 08:22:37.000000000 -0400
3 +++ ./src/ldgeneric.c   2016-05-04 15:20:09.029651147 -0400
4 @@ -1747,7 +1747,13 @@
5  
6           /* The content of the file is available in memory.  Read the
7              memory region as a stream.  */
8 +#ifdef __ANDROID__
9 +          ldin = tmpfile();
10 +          fwrite(content, 1, contentsize, ldin);
11 +          rewind(ldin);
12 +#else
13           ldin = fmemopen (content, contentsize, "r");
14 +#endif
15         }
16  
17        /* No need for locking.  */
18 @@ -2631,9 +2637,9 @@
19  /* Callback function registered with on_exit to make sure the temporary
20     files gets removed if something goes wrong.  */
21  static void
22 -remove_tempfile (int status, void *arg)
23 +remove_tempfile ()
24  {
25 -  if (status != 0 && ld_state.tempfname != NULL)
26 +  if (ld_state.tempfname != NULL)
27      unlink (ld_state.tempfname);
28  }
29  
30 @@ -2680,7 +2686,7 @@
31  
32    /* Make sure we remove the temporary file in case something goes
33       wrong.  */
34 -  on_exit (remove_tempfile, NULL);
35 +  atexit (remove_tempfile);
36  
37    /* Create the ELF file data for the output file.  */
38    Elf *elf = ld_state.outelf = elf_begin (fd,
39 @@ -3352,6 +3358,7 @@
40    struct id_list search;
41    struct id_list *verp;
42    bool result = ld_state.default_bind_local;
43 +  size_t substr_len;
44  
45    if (XELF_ST_BIND (sym->st_info) == STB_LOCAL || sym->st_shndx == SHN_UNDEF)
46      /* We don't have to do anything to local symbols here.  */
47 @@ -3367,7 +3374,12 @@
48    version = strchr (str, VER_CHR);
49    if (version != NULL)
50      {
51 -      search.id = strndupa (str, version - str);
52 +      substr_len = version - str;
53 +      char* tmp = alloca(substr_len+1);
54 +      strncpy(tmp, str, substr_len);
55 +      tmp[substr_len] = 0;
56 +      search.id = tmp;
57 +
58        if (*++version == VER_CHR)
59         /* Skip the second '@' signaling a default definition.  */
60         ++version;