am e0e7bce4: am 2b8ba2fa: Merge "Clean up warnings in soslim" into gingerbread

Merge commit 'e0e7bce46bbb9b6a057ed9e57700dbeb3e45d8c1'

* commit 'e0e7bce46bbb9b6a057ed9e57700dbeb3e45d8c1':
  Clean up warnings in soslim
This commit is contained in:
David Turner 2010-07-07 14:18:39 -07:00 committed by Android Git Automerger
commit c8a20b72ed
4 changed files with 33 additions and 26 deletions

View file

@ -337,7 +337,7 @@ static void print_dynamic_symbols(Elf *elf, const char *file)
section_name = "(undefined)";
}
/* value size binding type section symname */
PRINT("%-15s %8d: %08llx %08llx %c%c %5d %n%s%n",
PRINT("%-15s %8zd: %08llx %08llx %c%c %5d %n%s%n",
file,
index,
sym->st_value, sym->st_size, bind, type,

View file

@ -14,13 +14,13 @@
typedef struct {
uint32_t mmap_addr;
char tag[4]; /* 'P', 'R', 'E', ' ' */
} prelink_info_t __attribute__((packed));
} __attribute__((packed)) prelink_info_t;
static inline void set_prelink(long *prelink_addr,
int elf_little,
prelink_info_t *info)
{
FAILIF(sizeof(prelink_info_t) != 8, "Unexpected sizeof(prelink_info_t) == %d!\n", sizeof(prelink_info_t));
FAILIF(sizeof(prelink_info_t) != 8, "Unexpected sizeof(prelink_info_t) == %zd!\n", sizeof(prelink_info_t));
if (prelink_addr) {
if (!(elf_little ^ is_host_little())) {
/* Same endianness */
@ -35,11 +35,14 @@ static inline void set_prelink(long *prelink_addr,
int check_prelinked(const char *fname, int elf_little, long *prelink_addr)
{
FAILIF(sizeof(prelink_info_t) != 8, "Unexpected sizeof(prelink_info_t) == %d!\n", sizeof(prelink_info_t));
FAILIF(sizeof(prelink_info_t) != 8, "Unexpected sizeof(prelink_info_t) == %zd!\n", sizeof(prelink_info_t));
int fd = open(fname, O_RDONLY);
FAILIF(fd < 0, "open(%s, O_RDONLY): %s (%d)!\n",
fname, strerror(errno), errno);
off_t end = lseek(fd, 0, SEEK_END);
#ifndef DEBUG
(void)end;
#endif
int nr = sizeof(prelink_info_t);
@ -50,14 +53,14 @@ int check_prelinked(const char *fname, int elf_little, long *prelink_addr)
fd, strerror(errno), errno);
prelink_info_t info;
int num_read = read(fd, &info, nr);
ssize_t num_read = read(fd, &info, nr);
FAILIF(num_read < 0,
"read(%d, &info, sizeof(prelink_info_t)): %s (%d)!\n",
fd, strerror(errno), errno);
FAILIF(num_read != sizeof(info),
"read(%d, &info, sizeof(prelink_info_t)): did not read %d bytes as "
"expected (read %d)!\n",
fd, sizeof(info), num_read);
FAILIF((size_t)num_read != sizeof(info),
"read(%d, &info, sizeof(prelink_info_t)): did not read %zd bytes as "
"expected (read %zd)!\n",
fd, sizeof(info), (size_t)num_read);
int prelinked = 0;
if (!strncmp(info.tag, "PRE ", 4)) {
@ -70,7 +73,7 @@ int check_prelinked(const char *fname, int elf_little, long *prelink_addr)
void setup_prelink_info(const char *fname, int elf_little, long base)
{
FAILIF(sizeof(prelink_info_t) != 8, "Unexpected sizeof(prelink_info_t) == %d!\n", sizeof(prelink_info_t));
FAILIF(sizeof(prelink_info_t) != 8, "Unexpected sizeof(prelink_info_t) == %zd!\n", sizeof(prelink_info_t));
int fd = open(fname, O_WRONLY);
FAILIF(fd < 0,
"open(%s, O_WRONLY): %s (%d)\n" ,
@ -93,13 +96,13 @@ void setup_prelink_info(const char *fname, int elf_little, long base)
}
strncpy(info.tag, "PRE ", 4);
int num_written = write(fd, &info, sizeof(info));
ssize_t num_written = write(fd, &info, sizeof(info));
FAILIF(num_written < 0,
"write(%d, &info, sizeof(info)): %s (%d)\n",
fd, strerror(errno), errno);
FAILIF(sizeof(info) != num_written,
"Could not write %d bytes (wrote only %d bytes) as expected!\n",
sizeof(info), num_written);
FAILIF(sizeof(info) != (size_t)num_written,
"Could not write %zd bytes (wrote only %zd bytes) as expected!\n",
sizeof(info), (size_t)num_written);
FAILIF(close(fd) < 0, "close(%d): %s (%d)!\n", fd, strerror(errno), errno);
}

View file

@ -42,7 +42,7 @@ void clone_elf(Elf *elf, Elf *newelf,
int dynsym_idx = -1; /* index in shdr_info[] of dynamic symbol table
section */
int cnt; /* general-purpose counter */
unsigned int cnt; /* general-purpose counter */
/* This flag is true when at least one section is dropped or when the
relative order of sections has changed, so that section indices in
the resulting file will be different from those in the original. */
@ -51,7 +51,7 @@ void clone_elf(Elf *elf, Elf *newelf,
size_t idx; /* general-purporse section index */
shdr_info_t *shdr_info = NULL;
int shdr_info_len = 0;
unsigned int shdr_info_len = 0;
GElf_Phdr *phdr_info = NULL;
/* Get the information from the old file. */
@ -95,7 +95,7 @@ void clone_elf(Elf *elf, Elf *newelf,
/* Get the number of sections. */
FAILIF_LIBELF(elf_getshnum (elf, &shnum) < 0, elf_getshnum);
INFO("Original ELF file has %d sections.\n", shnum);
INFO("Original ELF file has %zd sections.\n", shnum);
/* Allocate the section-header-info buffer. We allocate one more entry
for the section-strings section because we regenerate that one and
@ -104,7 +104,7 @@ void clone_elf(Elf *elf, Elf *newelf,
one more section the header. We just mark the old section for removal
and create one as the last section.
*/
INFO("Allocating section-header info structure (%d) bytes...\n",
INFO("Allocating section-header info structure (%zd) bytes...\n",
shnum*sizeof (shdr_info_t));
shdr_info_len = rebuild_shstrtab ? shnum + 1 : shnum;
shdr_info = (shdr_info_t *)CALLOC(shdr_info_len, sizeof (shdr_info_t));
@ -305,9 +305,9 @@ void clone_elf(Elf *elf, Elf *newelf,
/* Check the length of the dynamic-symbol filter. */
FAILIF(sym_filter != NULL &&
num_symbols != symdata->d_size / elsize,
(size_t)num_symbols != symdata->d_size / elsize,
"Length of dynsym filter (%d) must equal the number"
" of dynamic symbols (%d)!\n",
" of dynamic symbols (%zd)!\n",
num_symbols,
symdata->d_size / elsize);
@ -443,14 +443,14 @@ void clone_elf(Elf *elf, Elf *newelf,
shdr_info[cnt].se = ebl_strtabadd (shst, shdr_info[cnt].name, 0);
INFO("\tsection [%s] (old offset %lld, old size %lld) will have index %d "
"(was %d).\n",
"(was %zd).\n",
shdr_info[cnt].name,
shdr_info[cnt].old_shdr.sh_offset,
shdr_info[cnt].old_shdr.sh_size,
shdr_info[cnt].idx,
elf_ndxscn(shdr_info[cnt].scn));
} else {
INFO("\tIgnoring section [%s] (offset %lld, size %lld, index %d), "
INFO("\tIgnoring section [%s] (offset %lld, size %lld, index %zd), "
"it will be discarded.\n",
shdr_info[cnt].name,
shdr_info[cnt].shdr.sh_offset,

View file

@ -38,9 +38,9 @@ void build_symfilter(const char *name, Elf *elf, symfilter_t *filter,
strerror(errno),
errno);
INFO("Symbol-filter file %s is %ld bytes long...\n",
INFO("Symbol-filter file %s is %zd bytes long...\n",
name,
fsize);
(size_t)fsize);
filter->fsize = fsize;
/* mmap the symbols file */
@ -48,8 +48,8 @@ void build_symfilter(const char *name, Elf *elf, symfilter_t *filter,
PROT_READ | PROT_WRITE, MAP_PRIVATE,
filter->fd, 0);
FAILIF(MAP_FAILED == filter->mmap,
"mmap(NULL, %ld, PROT_READ, MAP_PRIVATE, %d, 0): %s (%d)\n",
fsize,
"mmap(NULL, %zd, PROT_READ, MAP_PRIVATE, %d, 0): %s (%d)\n",
(size_t)fsize,
filter->fd,
strerror(errno),
errno);
@ -202,6 +202,8 @@ void destroy_symfilter(symfilter_t *filter)
static int match_hash_table_section(Elf *elf, Elf_Scn *sect, void *data)
{
(void)elf; // unused argument
symfilter_t *filter = (symfilter_t *)data;
Elf32_Shdr *shdr;
@ -224,6 +226,8 @@ static int match_hash_table_section(Elf *elf, Elf_Scn *sect, void *data)
static int match_dynsym_section(Elf *elf, Elf_Scn *sect, void *data)
{
(void)elf; // unused argument
symfilter_t *filter = (symfilter_t *)data;
Elf32_Shdr *shdr;