Send errors to stderr.
[ksplice.git] / objcommon.h
blobf8eca5cf50be090ef31cc61aab71566966d2c785
1 #include <bfd.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <string.h>
6 #define DIE do { fprintf(stderr, "ksplice: died at %s:%d\n", __FILE__, __LINE__); abort(); } while(0)
7 #define assert(x) do { if(!(x)) DIE; } while(0)
8 #define align(x, n) ((((x)+(n)-1)/(n))*(n))
10 #ifndef bfd_get_section_size
11 #define bfd_get_section_size(x) ((x)->_cooked_size)
12 #endif
14 struct supersect {
15 bfd *parent;
16 char *name;
17 void *contents;
18 int contents_size;
19 int alignment;
20 arelent **relocs;
21 int num_relocs;
22 struct supersect *next;
25 long get_syms(bfd *abfd, asymbol ***syms_ptr);
26 struct supersect *fetch_supersect(bfd *abfd, asection *sect, asymbol **sympp);
28 #define starts_with(str, prefix) \
29 (strncmp(str, prefix, strlen(prefix)) == 0)
30 #define ends_with(str, suffix) \
31 (strlen(str) >= strlen(suffix) && \
32 strcmp(&str[strlen(str) - strlen(suffix)], suffix) == 0)
34 int label_offset(const char *sym_name);
35 const char *only_label(const char *sym_name);
36 const char *dup_wolabel(const char *sym_name);