Commit 93f0d6ce authored by Laurent Dufour's avatar Laurent Dufour Committed by Pavel Emelyanov

piegen: opts variable is global

Since opts is defined as extern in piegen.h, there is no need to pass it as
argument.
Signed-off-by: 's avatarLaurent Dufour <ldufour@linux.vnet.ibm.com>
Acked-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 8c98ede3
......@@ -62,7 +62,7 @@ static int do_relative_toc(long value, uint16_t *location,
}
#endif
int handle_elf(const piegen_opt_t *opts, void *mem, size_t size)
int handle_elf(void *mem, size_t size)
{
const char *symstrings = NULL;
Shdr_t *symtab_hdr = NULL;
......@@ -154,7 +154,7 @@ int handle_elf(const piegen_opt_t *opts, void *mem, size_t size)
goto err;
}
pr_out("/* Autogenerated from %s */\n", opts->input_filename);
pr_out("/* Autogenerated from %s */\n", opts.input_filename);
pr_out("#include \"piegen/uapi/types.h\"\n");
for (i = 0; i < symtab_hdr->sh_size / symtab_hdr->sh_entsize; i++) {
......@@ -190,13 +190,13 @@ int handle_elf(const piegen_opt_t *opts, void *mem, size_t size)
ELF_ST_TYPE(sym->st_info) == STT_OBJECT)
#endif
pr_out("#define %s%s 0x%lx\n",
opts->prefix_name, name,
opts.prefix_name, name,
(unsigned long)(sym->st_value + sh_src->sh_addr));
}
}
}
pr_out("static __maybe_unused elf_reloc_t %s[] = {\n", opts->var_name);
pr_out("static __maybe_unused elf_reloc_t %s[] = {\n", opts.var_name);
pr_debug("Relocations\n------------\n");
for (i = 0; i < hdr->e_shnum; i++) {
......@@ -457,9 +457,9 @@ int handle_elf(const piegen_opt_t *opts, void *mem, size_t size)
}
}
pr_out("};\n");
pr_out("static __maybe_unused size_t %s = %zd;\n", opts->nrgotpcrel_name, nr_gotpcrel);
pr_out("static __maybe_unused size_t %s = %zd;\n", opts.nrgotpcrel_name, nr_gotpcrel);
pr_out("static __maybe_unused const char %s[] = {\n\t", opts->stream_name);
pr_out("static __maybe_unused const char %s[] = {\n\t", opts.stream_name);
for (i=0, k=0; i < hdr->e_shnum; i++) {
size_t j;
......
......@@ -27,7 +27,7 @@ piegen_opt_t opts = {
FILE *fout;
static int handle_elf(const piegen_opt_t *opts, void *mem, size_t size)
static int handle_elf(void *mem, size_t size)
{
#if defined(CONFIG_X86_32) || defined(CONFIG_X86_64)
unsigned char elf_ident_x86_32[EI_NIDENT] = {
......@@ -41,9 +41,9 @@ static int handle_elf(const piegen_opt_t *opts, void *mem, size_t size)
};
if (memcmp(mem, elf_ident_x86_32, sizeof(elf_ident_x86_32)) == 0)
return handle_elf_x86_32(opts, mem, size);
return handle_elf_x86_32(mem, size);
else if (memcmp(mem, elf_ident_x86_64, sizeof(elf_ident_x86_64)) == 0)
return handle_elf_x86_64(opts, mem, size);
return handle_elf_x86_64(mem, size);
#endif
#if defined(CONFIG_PPC64)
......@@ -58,7 +58,7 @@ static int handle_elf(const piegen_opt_t *opts, void *mem, size_t size)
};
if (memcmp(mem, elf_ident, sizeof(elf_ident)) == 0)
return handle_elf_ppc64(opts, mem, size);
return handle_elf_ppc64(mem, size);
#endif /* CONFIG_PPC64 */
pr_err("Unsupported Elf format detected\n");
......@@ -139,7 +139,7 @@ int main(int argc, char *argv[])
goto err;
}
if (handle_elf(&opts, mem, st.st_size)) {
if (handle_elf(mem, st.st_size)) {
fclose(fout);
unlink(opts.output_filename);
goto err;
......
......@@ -17,17 +17,17 @@ extern piegen_opt_t opts;
extern FILE *fout;
#if defined(CONFIG_X86_32) || defined(CONFIG_X86_64)
extern int handle_elf_x86_32(const piegen_opt_t *opts, void *mem, size_t size);
extern int handle_elf_x86_64(const piegen_opt_t *opts, void *mem, size_t size);
extern int handle_elf_x86_32(void *mem, size_t size);
extern int handle_elf_x86_64(void *mem, size_t size);
#endif
#if defined(CONFIG_PPC64)
extern int handle_elf_ppc64(const piegen_opt_t *opts, void *mem, size_t size);
extern int handle_elf_ppc64(void *mem, size_t size);
#endif
#define pr_out(fmt, ...) fprintf(fout, fmt, ##__VA_ARGS__)
#define pr_debug(fmt, ...) fprintf(stdout, fmt, ##__VA_ARGS__)
#define pr_debug(fmt, ...) printf(fmt, ##__VA_ARGS__)
#define pr_err(fmt, ...) fprintf(stderr, "Error (%s:%d): "fmt, __FILE__, __LINE__, ##__VA_ARGS__)
#define pr_perror(fmt, ...) fprintf(stderr, "Error (%s:%d): "fmt "%m\n", __FILE__, __LINE__, ##__VA_ARGS__)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment