diff options
Diffstat (limited to 'gcc/gcc.cc')
-rw-r--r-- | gcc/gcc.cc | 80 |
1 files changed, 45 insertions, 35 deletions
@@ -30,6 +30,9 @@ compilation is specified by a string called a "spec". */ #define INCLUDE_STRING #include "config.h" #include "system.h" +#ifdef HOST_HAS_PERSONALITY_ADDR_NO_RANDOMIZE +#include <sys/personality.h> +#endif #include "coretypes.h" #include "multilib.h" /* before tm.h */ #include "tm.h" @@ -7744,55 +7747,58 @@ print_configuration (FILE *file) #define RETRY_ICE_ATTEMPTS 3 -/* Returns true if FILE1 and FILE2 contain equivalent data, 0 otherwise. */ +/* Returns true if FILE1 and FILE2 contain equivalent data, 0 otherwise. + If lines start with 0x followed by 1-16 lowercase hexadecimal digits + followed by a space, ignore anything before that space. These are + typically function addresses from libbacktrace and those can differ + due to ASLR. */ static bool files_equal_p (char *file1, char *file2) { - struct stat st1, st2; - off_t n, len; - int fd1, fd2; - const int bufsize = 8192; - char *buf = XNEWVEC (char, bufsize); - - fd1 = open (file1, O_RDONLY); - fd2 = open (file2, O_RDONLY); - - if (fd1 < 0 || fd2 < 0) - goto error; - - if (fstat (fd1, &st1) < 0 || fstat (fd2, &st2) < 0) - goto error; + FILE *f1 = fopen (file1, "rb"); + FILE *f2 = fopen (file2, "rb"); + char line1[256], line2[256]; - if (st1.st_size != st2.st_size) - goto error; - - for (n = st1.st_size; n; n -= len) + bool line_start = true; + while (fgets (line1, sizeof (line1), f1)) { - len = n; - if ((int) len > bufsize / 2) - len = bufsize / 2; - - if (read (fd1, buf, len) != (int) len - || read (fd2, buf + bufsize / 2, len) != (int) len) + if (!fgets (line2, sizeof (line2), f2)) + goto error; + char *p1 = line1, *p2 = line2; + if (line_start + && line1[0] == '0' + && line1[1] == 'x' + && line2[0] == '0' + && line2[1] == 'x') { - goto error; + int i, j; + for (i = 0; i < 16; ++i) + if (!ISXDIGIT (line1[2 + i]) || ISUPPER (line1[2 + i])) + break; + for (j = 0; j < 16; ++j) + if (!ISXDIGIT (line2[2 + j]) || ISUPPER (line2[2 + j])) + break; + if (i && line1[2 + i] == ' ' && j && line2[2 + j] == ' ') + { + p1 = line1 + i + 3; + p2 = line2 + j + 3; + } } - - if (memcmp (buf, buf + bufsize / 2, len) != 0) + if (strcmp (p1, p2) != 0) goto error; + line_start = strchr (line1, '\n') != NULL; } + if (fgets (line2, sizeof (line2), f2)) + goto error; - free (buf); - close (fd1); - close (fd2); - + fclose (f1); + fclose (f2); return 1; error: - free (buf); - close (fd1); - close (fd2); + fclose (f1); + fclose (f2); return 0; } @@ -8000,6 +8006,10 @@ try_generate_repro (const char **argv) else new_argv[out_arg] = "-o-"; +#ifdef HOST_HAS_PERSONALITY_ADDR_NO_RANDOMIZE + personality (personality (0xffffffffU) | ADDR_NO_RANDOMIZE); +#endif + int status; for (attempt = 0; attempt < RETRY_ICE_ATTEMPTS; ++attempt) { |