1 |
/* |
/* |
2 |
* Copyright (C) 2003-2005 Anders Gavare. All rights reserved. |
* Copyright (C) 2003-2006 Anders Gavare. All rights reserved. |
3 |
* |
* |
4 |
* Redistribution and use in source and binary forms, with or without |
* Redistribution and use in source and binary forms, with or without |
5 |
* modification, are permitted provided that the following conditions are met: |
* modification, are permitted provided that the following conditions are met: |
25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: symbol.c,v 1.29 2005/08/09 17:18:22 debug Exp $ |
* $Id: symbol.c,v 1.36 2006/07/07 19:38:55 debug Exp $ |
29 |
* |
* |
30 |
* Address to symbol translation routines. |
* Address to symbol translation routines. |
31 |
* |
* |
32 |
* This module is (probably) independant from the rest of the emulator. |
* This module is (probably) independent from the rest of the emulator. |
33 |
* symbol_init() must be called before any other function in this |
* symbol_init() must be called before any other function in this file is used. |
|
* file is used. |
|
34 |
*/ |
*/ |
35 |
|
|
36 |
#include <stdio.h> |
#include <stdio.h> |
37 |
#include <stdlib.h> |
#include <stdlib.h> |
38 |
#include <string.h> |
#include <string.h> |
39 |
|
|
|
#include "misc.h" |
|
|
|
|
40 |
#include "symbol.h" |
#include "symbol.h" |
41 |
|
|
42 |
|
|
224 |
exit(1); |
exit(1); |
225 |
} |
} |
226 |
|
|
227 |
|
if (addr == 0 && strcmp(name, "_DYNAMIC_LINK") == 0) |
228 |
|
return; |
229 |
|
|
230 |
if (name[0] == '\0') |
if (name[0] == '\0') |
231 |
return; |
return; |
232 |
|
|
242 |
n_args = 2; |
n_args = 2; |
243 |
if (strcmp(name, "strcpy") == 0) |
if (strcmp(name, "strcpy") == 0) |
244 |
n_args = 2; |
n_args = 2; |
245 |
|
if (strcmp(name, "strncpy") == 0) |
246 |
|
n_args = 3; |
247 |
|
if (strcmp(name, "strlcpy") == 0) |
248 |
|
n_args = 3; |
249 |
|
if (strcmp(name, "strlcat") == 0) |
250 |
|
n_args = 3; |
251 |
if (strcmp(name, "strncmp") == 0) |
if (strcmp(name, "strncmp") == 0) |
252 |
n_args = 3; |
n_args = 3; |
253 |
if (strcmp(name, "memset") == 0) |
if (strcmp(name, "memset") == 0) |
269 |
exit(1); |
exit(1); |
270 |
} |
} |
271 |
|
|
272 |
s->name = strdup(name); |
memset(s, 0, sizeof(struct symbol)); |
273 |
|
|
274 |
|
s->name = symbol_demangle_cplusplus(name); |
275 |
|
|
276 |
if (s->name == NULL) { |
if (s->name == NULL) { |
277 |
fprintf(stderr, "out of memory\n"); |
s->name = strdup(name); |
278 |
exit(1); |
if (s->name == NULL) { |
279 |
|
fprintf(stderr, "out of memory\n"); |
280 |
|
exit(1); |
281 |
|
} |
282 |
} |
} |
283 |
|
|
284 |
s->addr = addr; |
s->addr = addr; |
285 |
s->len = len; |
s->len = len; |
286 |
s->type = type; |
s->type = type; |