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.35 2006/03/22 21:39:23 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 |
|
|
239 |
n_args = 2; |
n_args = 2; |
240 |
if (strcmp(name, "strcpy") == 0) |
if (strcmp(name, "strcpy") == 0) |
241 |
n_args = 2; |
n_args = 2; |
242 |
|
if (strcmp(name, "strncpy") == 0) |
243 |
|
n_args = 3; |
244 |
|
if (strcmp(name, "strlcpy") == 0) |
245 |
|
n_args = 3; |
246 |
|
if (strcmp(name, "strlcat") == 0) |
247 |
|
n_args = 3; |
248 |
if (strcmp(name, "strncmp") == 0) |
if (strcmp(name, "strncmp") == 0) |
249 |
n_args = 3; |
n_args = 3; |
250 |
if (strcmp(name, "memset") == 0) |
if (strcmp(name, "memset") == 0) |
266 |
exit(1); |
exit(1); |
267 |
} |
} |
268 |
|
|
269 |
s->name = strdup(name); |
memset(s, 0, sizeof(struct symbol)); |
270 |
|
|
271 |
|
s->name = symbol_demangle_cplusplus(name); |
272 |
|
|
273 |
if (s->name == NULL) { |
if (s->name == NULL) { |
274 |
fprintf(stderr, "out of memory\n"); |
s->name = strdup(name); |
275 |
exit(1); |
if (s->name == NULL) { |
276 |
|
fprintf(stderr, "out of memory\n"); |
277 |
|
exit(1); |
278 |
|
} |
279 |
} |
} |
280 |
|
|
281 |
s->addr = addr; |
s->addr = addr; |
282 |
s->len = len; |
s->len = len; |
283 |
s->type = type; |
s->type = type; |