scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

commit e4dd267e90a51c92c686028f118a0fc835e72620
parent 97caea2d7a7e55453218c4457a18f4c692b2ac52
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sat, 16 May 2020 20:10:11 +0200

libc: Fix _getheap() for linux

Linux is adding randomization to brk() calls, which means that
it breaksall the software using brk() that was also using the
end symbol. This patch modifies _getheap() to use brk(0) to
obtain the base of the heap.

Diffstat:
Msrc/libc/arch/amd64/linux/_getheap.c | 2+-
Msrc/libc/arch/amd64/netbsd/crt.s | 2+-
Msrc/libc/arch/amd64/openbsd/crt.s | 2+-
Msrc/libc/arch/arm32/linux/_getheap.c | 2+-
Msrc/libc/arch/arm64/linux/_getheap.c | 2+-
Msrc/libc/arch/i386/linux/_getheap.c | 2+-
Asrc/libc/arch/linux/_getheap.c | 10++++++++++
Rsrc/libc/arch/crt-netbsd.s -> src/libc/arch/netbsd/crt.s | 0
Rsrc/libc/arch/crt-openbsd.s -> src/libc/arch/openbsd/crt.s | 0
Msrc/libc/arch/ppc32/linux/_getheap.c | 2+-
10 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/src/libc/arch/amd64/linux/_getheap.c b/src/libc/arch/amd64/linux/_getheap.c @@ -1 +1 @@ -#include "../../posix/_getheap.c" +#include "../../linux/_getheap.c" diff --git a/src/libc/arch/amd64/netbsd/crt.s b/src/libc/arch/amd64/netbsd/crt.s @@ -1,2 +1,2 @@ - .include "../../crt-netbsd.s" + .include "../../netbsd/crt.s" .include "../crt-posix.s" diff --git a/src/libc/arch/amd64/openbsd/crt.s b/src/libc/arch/amd64/openbsd/crt.s @@ -1,2 +1,2 @@ - .include "../../crt-openbsd.s" + .include "../../openbsd/crt.s" .include "../crt-posix.s" diff --git a/src/libc/arch/arm32/linux/_getheap.c b/src/libc/arch/arm32/linux/_getheap.c @@ -1 +1 @@ -#include "../../posix/_getheap.c" +#include "../../linux/_getheap.c" diff --git a/src/libc/arch/arm64/linux/_getheap.c b/src/libc/arch/arm64/linux/_getheap.c @@ -1 +1 @@ -#include "../../posix/_getheap.c" +#include "../../linux/_getheap.c" diff --git a/src/libc/arch/i386/linux/_getheap.c b/src/libc/arch/i386/linux/_getheap.c @@ -1 +1 @@ -#include "../../posix/_getheap.c" +#include "../../linux/_getheap.c" diff --git a/src/libc/arch/linux/_getheap.c b/src/libc/arch/linux/_getheap.c @@ -0,0 +1,10 @@ +#include <stddef.h> + +#include "../../libc.h" +#include "../../syscall.h" + +void * +_getheap(void) +{ + return _brk(0); +} diff --git a/src/libc/arch/crt-netbsd.s b/src/libc/arch/netbsd/crt.s diff --git a/src/libc/arch/crt-openbsd.s b/src/libc/arch/openbsd/crt.s diff --git a/src/libc/arch/ppc32/linux/_getheap.c b/src/libc/arch/ppc32/linux/_getheap.c @@ -1 +1 @@ -#include "../../posix/_getheap.c" +#include "../../linux/_getheap.c"