2015-06-05 00:04:02 +03:00
|
|
|
#ifndef __ELFTIL_H__
|
|
|
|
#define __ELFTIL_H__
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
2016-04-29 22:47:00 +03:00
|
|
|
#include <elf.h>
|
|
|
|
#include "compiler.h"
|
|
|
|
|
2015-06-05 00:04:02 +03:00
|
|
|
typedef struct {
|
|
|
|
char *input_filename;
|
2015-06-10 15:00:40 +02:00
|
|
|
char *output_filename;
|
2016-04-05 18:41:12 +03:00
|
|
|
char *uapi_dir;
|
2015-06-05 00:04:02 +03:00
|
|
|
char *stream_name;
|
|
|
|
char *prefix_name;
|
|
|
|
char *var_name;
|
|
|
|
char *nrgotpcrel_name;
|
|
|
|
} piegen_opt_t;
|
|
|
|
|
|
|
|
extern piegen_opt_t opts;
|
2015-06-10 15:00:40 +02:00
|
|
|
extern FILE *fout;
|
2015-06-05 00:04:02 +03:00
|
|
|
|
2015-06-10 15:00:40 +02:00
|
|
|
#define pr_out(fmt, ...) fprintf(fout, fmt, ##__VA_ARGS__)
|
2015-06-05 00:04:02 +03:00
|
|
|
|
2015-06-10 15:00:42 +02:00
|
|
|
#define pr_debug(fmt, ...) printf("%s: "fmt, opts.stream_name, ##__VA_ARGS__)
|
2015-06-05 00:04:02 +03:00
|
|
|
|
2015-06-10 15:00:42 +02:00
|
|
|
#define pr_err(fmt, ...) fprintf(stderr, "%s: Error (%s:%d): "fmt, opts.stream_name, __FILE__, __LINE__, ##__VA_ARGS__)
|
2016-02-17 14:23:58 +03:00
|
|
|
#define pr_perror(fmt, ...) fprintf(stderr, "%s: Error (%s:%d): "fmt ": %m\n", opts.stream_name, __FILE__, __LINE__, ##__VA_ARGS__)
|
2015-06-05 00:04:02 +03:00
|
|
|
|
2016-04-29 22:47:00 +03:00
|
|
|
extern int handle_binary(void *mem, size_t size);
|
|
|
|
|
|
|
|
static const unsigned char __maybe_unused
|
|
|
|
elf_ident_32[EI_NIDENT] = {
|
|
|
|
0x7f, 0x45, 0x4c, 0x46, 0x01, 0x01, 0x01, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
};
|
|
|
|
static const unsigned char __maybe_unused
|
|
|
|
elf_ident_64_le[EI_NIDENT] = {
|
|
|
|
0x7f, 0x45, 0x4c, 0x46, 0x02, 0x01, 0x01, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
};
|
|
|
|
static const unsigned char __maybe_unused
|
|
|
|
elf_ident_64_be[EI_NIDENT] = {
|
|
|
|
0x7f, 0x45, 0x4c, 0x46, 0x02, 0x02, 0x01, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
};
|
|
|
|
|
2015-06-05 00:04:02 +03:00
|
|
|
#endif /* __ELFTIL_H__ */
|