mirror of
https://github.com/openharmony/third_party_elfutils.git
synced 2026-07-19 19:43:34 -04:00
Move recursive nested function to file scope.
Prepare src/ld.c to compile with clang. Signed-off-by: Chih-Hung Hsieh <chh@google.com>
This commit is contained in:
committed by
Mark Wielaard
parent
c53857b6a8
commit
57fa86e08b
@@ -1,3 +1,8 @@
|
||||
2015-10-08 Chih-Hung Hsieh <chh@google.com>
|
||||
|
||||
* ld.c (determine_output_format): Move recursive nested
|
||||
function "try" to file scope.
|
||||
|
||||
2015-10-04 Mark Wielaard <mjw@redhat.com>
|
||||
|
||||
* strip.c (handle_elf): Only sanity check section symbols to not
|
||||
|
||||
@@ -1049,6 +1049,53 @@ parse_B_option_2 (const char *arg)
|
||||
}
|
||||
|
||||
|
||||
static inline int
|
||||
try (int fd, Elf *elf)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
if (elf == NULL)
|
||||
return 0;
|
||||
|
||||
if (elf_kind (elf) == ELF_K_ELF)
|
||||
{
|
||||
/* We have an ELF file. We now can find out
|
||||
what the output format should be. */
|
||||
XElf_Ehdr_vardef(ehdr);
|
||||
|
||||
/* Get the ELF header of the object. */
|
||||
xelf_getehdr (elf, ehdr);
|
||||
if (ehdr != NULL)
|
||||
ld_state.ebl =
|
||||
ebl_openbackend_machine (ehdr->e_machine);
|
||||
|
||||
result = 1;
|
||||
}
|
||||
else if (elf_kind (elf) == ELF_K_AR)
|
||||
{
|
||||
/* Try the archive members. This could
|
||||
potentially lead to wrong results if the
|
||||
archive contains files for more than one
|
||||
architecture. But this is the user's
|
||||
problem. */
|
||||
Elf *subelf;
|
||||
Elf_Cmd cmd = ELF_C_READ_MMAP;
|
||||
|
||||
while ((subelf = elf_begin (fd, cmd, elf)) != NULL)
|
||||
{
|
||||
cmd = elf_next (subelf);
|
||||
|
||||
if (try (fd, subelf) != 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
elf_end (elf);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
determine_output_format (void)
|
||||
{
|
||||
@@ -1078,52 +1125,7 @@ determine_output_format (void)
|
||||
int fd = open (runp->name, O_RDONLY);
|
||||
if (fd != -1)
|
||||
{
|
||||
int try (Elf *elf)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
if (elf == NULL)
|
||||
return 0;
|
||||
|
||||
if (elf_kind (elf) == ELF_K_ELF)
|
||||
{
|
||||
/* We have an ELF file. We now can find out
|
||||
what the output format should be. */
|
||||
XElf_Ehdr_vardef(ehdr);
|
||||
|
||||
/* Get the ELF header of the object. */
|
||||
xelf_getehdr (elf, ehdr);
|
||||
if (ehdr != NULL)
|
||||
ld_state.ebl =
|
||||
ebl_openbackend_machine (ehdr->e_machine);
|
||||
|
||||
result = 1;
|
||||
}
|
||||
else if (elf_kind (elf) == ELF_K_AR)
|
||||
{
|
||||
/* Try the archive members. This could
|
||||
potentially lead to wrong results if the
|
||||
archive contains files for more than one
|
||||
architecture. But this is the user's
|
||||
problem. */
|
||||
Elf *subelf;
|
||||
Elf_Cmd cmd = ELF_C_READ_MMAP;
|
||||
|
||||
while ((subelf = elf_begin (fd, cmd, elf)) != NULL)
|
||||
{
|
||||
cmd = elf_next (subelf);
|
||||
|
||||
if (try (subelf) != 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
elf_end (elf);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
if (try (elf_begin (fd, ELF_C_READ_MMAP, NULL)) != 0)
|
||||
if (try (fd, elf_begin (fd, ELF_C_READ_MMAP, NULL)) != 0)
|
||||
/* Found a file. */
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user