X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=ginge.git;a=blobdiff_plain;f=loader%2Fdl.c;h=468a2e0d0c2e9c6d90da33af6789a8db43213ddf;hp=154e01236bd173bfa7e1549e908f377f2a152bc4;hb=4d0451847a77d420284c7fb0f50b1f167c1118ee;hpb=ed233fce977d411ce024631668f1488d0d078d19 diff --git a/loader/dl.c b/loader/dl.c index 154e012..468a2e0 100644 --- a/loader/dl.c +++ b/loader/dl.c @@ -9,6 +9,14 @@ #define DL #include "override.c" +static void next_line(FILE *f) +{ + int c; + do { + c = fgetc(f); + } while (c != EOF && c != '\n'); +} + __attribute__((constructor)) static void ginge_init(void) { @@ -32,7 +40,7 @@ static void ginge_init(void) exit(1); } - ret = fscanf(f, "%x-%x %*s %*s %*s %*s %*s\n", &start, &end); + ret = fscanf(f, "%x-%x ", &start, &end); if (ret != 2) { perror("parse maps"); exit(1); @@ -46,6 +54,8 @@ static void ginge_init(void) perror("warning: mprotect"); while (1) { + next_line(f); + ret = fscanf(f, "%x-%*s %*s %*s %*s %*s %*s\n", &start); if (ret <= 0) break; @@ -62,6 +72,10 @@ static void ginge_init(void) #endif fclose(f); + // remove self from preload, further commands (from system() and such) + // will be handled by ginge_prep. + unsetenv("LD_PRELOAD"); + emu_init((void *)lowest_segment); }