2 Copyright © 1995-2009, 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
119 void parse_secname(const char *secname
, setnode
**setlist_ptr
)
125 if (strncmp(secname
, ".aros.set.", 10) == 0)
128 if (strncmp(secname
, ".ctors", 5) == 0)
131 if (strncmp(secname
, ".dtors", 5) == 0)
136 idx
= strchr(secname
+ off
, '.');
140 pri
= strtol(&idx
[1], NULL
, 10);
143 get_setnode(setlist_ptr
, secname
, off
, pri
);
146 void parse_format(const char *format
)
148 if (strncmp(format
, "elf64", 5) == 0) {
149 pointer_size
= "QUAD";