summaryrefslogtreecommitdiffstats
path: root/trunk/src/dso.c
diff options
context:
space:
mode:
Diffstat (limited to 'trunk/src/dso.c')
-rw-r--r--trunk/src/dso.c55
1 files changed, 34 insertions, 21 deletions
diff --git a/trunk/src/dso.c b/trunk/src/dso.c
index afafe64..8ad93d3 100644
--- a/trunk/src/dso.c
+++ b/trunk/src/dso.c
@@ -115,6 +115,8 @@ read_dynamic (DSO *dso)
dso->info_DT_MIPS_GOTSYM = dyn.d_un.d_val;
else if (dyn.d_tag == DT_MIPS_SYMTABNO)
dso->info_DT_MIPS_SYMTABNO = dyn.d_un.d_val;
+ else if (dyn.d_tag == DT_MIPS_PLTGOT)
+ dso->info_DT_MIPS_PLTGOT = dyn.d_un.d_val;
}
}
if (ndx < maxndx)
@@ -229,7 +231,7 @@ open_dso (const char *name)
{
int fd;
- fd = open (name, O_RDONLY);
+ fd = wrap_open (name, O_RDONLY);
if (fd == -1)
{
error (0, errno, "cannot open \"%s\"", name);
@@ -515,7 +517,7 @@ fdopen_dso (int fd, const char *name)
const char *soname;
soname = get_data (dso, dso->info[DT_STRTAB] + dso->info[DT_SONAME],
- NULL);
+ NULL, NULL);
if (soname && soname[0] != '\0')
dso->soname = (const char *) strdup (soname);
}
@@ -551,7 +553,10 @@ error_out:
if (elf)
elf_end (elf);
if (fd != -1)
- close (fd);
+ {
+ fsync (fd);
+ close (fd);
+ }
return NULL;
}
@@ -765,15 +770,15 @@ reopen_dso (DSO *dso, struct section_move *move, const char *temp_base)
temp_base = dso->filename;
sprintf (filename, "%s.#prelink#.XXXXXX", temp_base);
- fd = mkstemp (filename);
+ fd = wrap_mkstemp (filename);
if (fd == -1)
{
strcpy (filename, "/tmp/#prelink#.XXXXXX");
- fd = mkstemp (filename);
+ fd = wrap_mkstemp (filename);
if (fd == -1)
{
strcpy (filename, "/dev/shm/#prelink#.XXXXXX");
- fd = mkstemp (filename);
+ fd = wrap_mkstemp (filename);
}
if (fd == -1)
{
@@ -1015,7 +1020,8 @@ error_out:
elf_end (elf);
if (fd != -1)
{
- unlink (filename);
+ wrap_unlink (filename);
+ fsync (fd);
close (fd);
}
return 1;
@@ -1030,7 +1036,9 @@ adjust_symbol_p (DSO *dso, GElf_Sym *sym)
{
if (sym->st_shndx == SHN_ABS
&& sym->st_value != 0
- && GELF_ST_TYPE (sym->st_info) <= STT_FUNC)
+ && (GELF_ST_TYPE (sym->st_info) <= STT_FUNC
+ || (dso->ehdr.e_machine == EM_ARM
+ && GELF_ST_TYPE (sym->st_info) == STT_ARM_TFUNC)))
/* This is problematic. How do we find out if
we should relocate this? Assume we should. */
return 1;
@@ -1404,12 +1412,15 @@ adjust_dso (DSO *dso, GElf_Addr start, GElf_Addr adjust)
return 1;
break;
case SHT_REL:
- if (adjust_rel (dso, i, start, adjust))
- return 1;
+ /* Don't adjust reloc sections for debug info. */
+ if (dso->shdr[i].sh_flags & SHF_ALLOC)
+ if (adjust_rel (dso, i, start, adjust))
+ return 1;
break;
case SHT_RELA:
- if (adjust_rela (dso, i, start, adjust))
- return 1;
+ if (dso->shdr[i].sh_flags & SHF_ALLOC)
+ if (adjust_rela (dso, i, start, adjust))
+ return 1;
break;
}
if ((dso->arch->machine == EM_ALPHA
@@ -1630,10 +1641,12 @@ close_dso_1 (DSO *dso)
}
elf_end (dso->elf);
+ fsync (dso->fd);
close (dso->fd);
if (dso->elfro)
{
elf_end (dso->elfro);
+ fsync (dso->fdro);
close (dso->fdro);
}
if (dso->filename != dso->soname)
@@ -1653,7 +1666,7 @@ close_dso (DSO *dso)
int rdwr = dso_is_rdwr (dso);
if (rdwr && dso->temp_filename != NULL)
- unlink (dso->temp_filename);
+ wrap_unlink (dso->temp_filename);
close_dso_1 (dso);
return 0;
}
@@ -1778,19 +1791,19 @@ update_dso (DSO *dso, const char *orig_name)
close_dso_1 (dso);
u.actime = time (NULL);
u.modtime = st.st_mtime;
- utime (name2, &u);
+ wrap_utime (name2, &u);
if (set_security_context (name2, orig_name ? orig_name : name1,
orig_name != NULL))
{
if (fdin != -1)
close (fdin);
- unlink (name2);
+ wrap_unlink (name2);
return 1;
}
if ((orig_name != NULL && strcmp (name1, "-") == 0)
- || rename (name2, name1))
+ || wrap_rename (name2, name1))
{
if (fdin != -1)
{
@@ -1800,7 +1813,7 @@ update_dso (DSO *dso, const char *orig_name)
if (strcmp (name1, "-") == 0)
fdout = 1;
else
- fdout = open (name1, O_WRONLY | O_CREAT, 0600);
+ fdout = wrap_open (name1, O_WRONLY | O_CREAT, 0600);
if (fdout != -1
&& fstat64 (fdin, &stt) >= 0
&& send_file (fdout, fdin, &off, stt.st_size) == stt.st_size)
@@ -1811,10 +1824,10 @@ update_dso (DSO *dso, const char *orig_name)
if (strcmp (name1, "-") != 0)
{
set_security_context (name1, name1, 1);
- utime (name1, &u);
+ wrap_utime (name1, &u);
close (fdout);
}
- unlink (name2);
+ wrap_unlink (name2);
return 0;
}
else if (fdout != -1)
@@ -1826,12 +1839,12 @@ update_dso (DSO *dso, const char *orig_name)
else
err = errno;
close (fdin);
- unlink (name2);
+ wrap_unlink (name2);
error (0, err, "Could not rename nor copy temporary to %s",
name1);
return 1;
}
- unlink (name2);
+ wrap_unlink (name2);
error (0, errno, "Could not rename temporary to %s", name1);
return 1;
}