From 76c6e4b7874d38ede7f7bf1fbdcf95973a1b1094 Mon Sep 17 00:00:00 2001 From: andrew Date: Mon, 11 May 2015 20:33:46 +0000 Subject: [PATCH] Use the GOT_* macros to help simplify the code, these work with both pic and non-pic code, and to build for Thumb. --- lib/libc/arm/sys/brk.S | 18 +++++------------- lib/libc/arm/sys/sbrk.S | 17 ++++------------- 2 files changed, 9 insertions(+), 26 deletions(-) diff --git a/lib/libc/arm/sys/brk.S b/lib/libc/arm/sys/brk.S index f3d8d8751524..e5f833637d09 100644 --- a/lib/libc/arm/sys/brk.S +++ b/lib/libc/arm/sys/brk.S @@ -53,16 +53,10 @@ _C_LABEL(minbrk): * Change the data segment size */ ENTRY(_brk) -#ifdef PIC /* Setup the GOT */ - ldr r3, .Lgot - add r3, pc, r3 -.L1: - ldr r1, .Lminbrk - ldr r1, [r3, r1] -#else - ldr r1, .Lminbrk -#endif + GOT_INIT(r3, .Lgot, .L1) + GOT_GET(r1, r3, .Lminbrk) + /* Get the minimum allowable brk address */ ldr r1, [r1] @@ -71,6 +65,7 @@ ENTRY(_brk) * if the address is below minbrk. */ cmp r0, r1 + it lt movlt r0, r1 mov r2, r0 SYSTRAP(break) @@ -90,10 +85,7 @@ ENTRY(_brk) RET .align 2 -#ifdef PIC -.Lgot: - .word _GLOBAL_OFFSET_TABLE_ - (.L1+4) -#endif + GOT_INITSYM(.Lgot, .L1) .Lminbrk: .word PIC_SYM(_C_LABEL(minbrk), GOT) .Lcurbrk: diff --git a/lib/libc/arm/sys/sbrk.S b/lib/libc/arm/sys/sbrk.S index 7d22aa7d7ce0..5cd9a03e3a80 100644 --- a/lib/libc/arm/sys/sbrk.S +++ b/lib/libc/arm/sys/sbrk.S @@ -52,16 +52,10 @@ CURBRK: * Change the data segment size */ ENTRY(_sbrk) -#ifdef PIC /* Setup the GOT */ - ldr r3, .Lgot - add r3, pc, r3 -.L1: - ldr r2, .Lcurbrk - ldr r2, [r3, r2] -#else - ldr r2, .Lcurbrk -#endif + GOT_INIT(r3, .Lgot, .L1) + GOT_GET(r2, r3, .Lcurbrk) + /* Get the current brk address */ ldr r1, [r2] @@ -80,10 +74,7 @@ ENTRY(_sbrk) RET .align 0 -#ifdef PIC -.Lgot: - .word _GLOBAL_OFFSET_TABLE_ - (.L1+4) -#endif + GOT_INITSYM(.Lgot, .L1) .Lcurbrk: .word PIC_SYM(CURBRK, GOT) END(_sbrk)