diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2013-10-14 14:49:26 +0200 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2013-10-14 14:49:26 +0200 |
commit | 747412b8fe223d4ab3e0ed55faac7a786b7a098b (patch) | |
tree | 66de19920b726e825ced45159306ee7898b3518f /gcc/ada/adaint.c | |
parent | 3599a97bc3f0b10b87d450a7228cb86edffacabf (diff) | |
download | gcc-747412b8fe223d4ab3e0ed55faac7a786b7a098b.zip gcc-747412b8fe223d4ab3e0ed55faac7a786b7a098b.tar.gz gcc-747412b8fe223d4ab3e0ed55faac7a786b7a098b.tar.bz2 |
[multiple changes]
2013-10-14 Vincent Celier <celier@adacore.com>
* projects.texi: Add documentation for new attributes of package
Clean: Artifacts_In_Object_Dir and Artifacts_In_Exec_Dir.
2013-10-14 Tristan Gingold <gingold@adacore.com>
* adaint.c, adaint.h (__gnat_get_executable_load_address):
New function.
* a-exexda.adb (Append_Info_Basic_Exception_Traceback): Add
executable load address (Basic_Exception_Tback_Maxlength): Adjust.
From-SVN: r203530
Diffstat (limited to 'gcc/ada/adaint.c')
-rw-r--r-- | gcc/ada/adaint.c | 57 |
1 files changed, 54 insertions, 3 deletions
diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c index f76edb7..5b261af 100644 --- a/gcc/ada/adaint.c +++ b/gcc/ada/adaint.c @@ -3830,8 +3830,8 @@ void GetTimeAsFileTime(LPFILETIME pTime) extern void __main (void); void __main (void) {} -#endif -#endif +#endif /* RTSS */ +#endif /* RTX */ #if defined (__ANDROID__) @@ -3889,7 +3889,7 @@ void __gnat_cpu_set (int cpu, size_t count, cpu_set_t *set) CPU_SET_S (cpu - 1, count, set); } -#else +#else /* !CPU_ALLOC */ /* Static cpu sets */ @@ -3919,8 +3919,59 @@ void __gnat_cpu_set (int cpu, size_t count ATTRIBUTE_UNUSED, cpu_set_t *set) CPU by a 0, so we need to adjust. */ CPU_SET (cpu - 1, set); } +#endif /* !CPU_ALLOC */ +#endif /* linux */ + +/* Return the load address of the executable, or 0 if not known. In the + specific case of error, (void *)-1 can be returned. Beware: this unit may + be in a shared library. As low-level units are needed, we allow #include + here. */ + +#if defined (__APPLE__) +#include <mach-o/dyld.h> +#elif defined (__linux__) +#include <link.h> +#elif defined (__AIX__) +#include <sys/ldr.h> #endif + +const void * +__gnat_get_executable_load_address (void) +{ +#if defined (__APPLE__) + return _dyld_get_image_header (0); + +#elif defined (__linux__) + struct link_map *map = _r_debug.r_map; + + return (const void *)map->l_addr; + +#elif defined (__AIX__) + /* Unfortunately, AIX wants to return the info for all loaded objects, + so we need to increase the buffer if too small. */ + size_t blen = 4096; + int status; + + while (1) + { + char buf[blen]; + + status = loadquery (L_GETINFO, buf, blen); + if (status == 0) + { + struct ldinfo *info = (struct ld_info *)buf; + return info->ldinfo_textorg; + } + blen = blen * 2; + + /* Avoid stack overflow. */ + if (blen > 40 * 1024) + return (const void *)-1; + } +#else + return NULL; #endif +} #ifdef __cplusplus } |