Use the GOT_* macros to help simplify the code, these work with both pic

and non-pic code, and to build for Thumb.
This commit is contained in:
andrew 2015-05-11 20:33:46 +00:00
parent e4e7fd4992
commit 76c6e4b787
2 changed files with 9 additions and 26 deletions

View File

@ -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:

View File

@ -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)