2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
14 typedef struct setnode
22 static char* pointer_size
= "LONG";
23 static char pointer_bytes
= 4;
25 static setnode
*new_setnode(const char *name
, setnode
*next
, int off
, long pri
){
28 if (!(n
= calloc(1, sizeof(setnode
))) ||
29 !(n
->secname
= strdup(name
))
32 fatal("new_setnode()", strerror(errno
));
42 static setnode
*get_setnode(setnode
**list
, const char *name
, int off
, long pri
)
44 setnode
**curr
= list
;
48 if (strcmp((*curr
)->secname
, name
) == 0)
52 if ((*curr
)->pri
== pri
)
55 if ((*curr
)->pri
> pri
)
58 curr
= &(*curr
)->next
;
60 } while (*curr
&& strcmp((*curr
)->secname
, name
) == 0);
65 curr
= &(*curr
)->next
;
68 return (*curr
= new_setnode(name
, *curr
, off
, pri
));
71 void emit_sets(setnode
*setlist
, FILE *out
)
73 char setname_big
[201];
78 setnode
*oldnode
= setlist
;
83 setname_big
[i
] = toupper(setlist
->secname
[setlist
->off_setname
+ i
]);
84 } while (setlist
->secname
[setlist
->off_setname
+ i
++]);
90 " %s((__%s_END__ - __%s_LIST__) / %d - 2)\n",
91 setname_big
, pointer_size
, setname_big
, setname_big
, pointer_bytes
100 setlist
->secname
, setlist
->pri
103 setlist
= setlist
->next
;
104 } while (setlist
&& (strcmp(oldnode
->secname
, setlist
->secname
) == 0));
112 " __%s_END__ = .;\n",
113 oldnode
->secname
, pointer_size
, setname_big
120 .ctors/.dtors - up to GCC 4.6 this was the default section where static
121 C++ constructors were placed for majority of targets.
122 .init_array/.fini_array - ARM EABI uses these sections to place static
124 As of GCC 4.6 the constructors can be placed in .init_array/.fini_array
128 void parse_secname(const char *secname
, setnode
**setlist_ptr
)
134 if (strncmp(secname
, ".aros.set.", 10) == 0)
137 if (strncmp(secname
, ".ctors", 5) == 0)
140 if (strncmp(secname
, ".dtors", 5) == 0)
143 if (strncmp(secname
, ".init_array", 11) == 0)
146 if (strncmp(secname
, ".fini_array", 11) == 0)
151 idx
= strchr(secname
+ off
, '.');
155 pri
= strtol(&idx
[1], NULL
, 10);
158 get_setnode(setlist_ptr
, secname
, off
, pri
);
161 void parse_format(const char *format
)
163 if (strncmp(format
, "elf64", 5) == 0) {
164 pointer_size
= "QUAD";
169 void emit_libs(setnode
*liblist
, FILE *out
)
172 fprintf(out
, "PROVIDE(%s = .); LONG(%ld)\n", liblist
->secname
, liblist
->pri
);
173 liblist
= liblist
->next
;