EDIT: The suggested commented solution (to use exit() not _exit) was unhelpful as there is no such system call number I can find. But a better solution is to explicitly ask Linux to flush any output in the C function: using fflush.
I have an issue where if I call my C function (foo) using 'b', it runs infinitely often, but if I call it with 'bl' it doesn't run at all! Does anyone know what I'm doing wrong? My files are below:
Makefile
TARGET      := APP
ENTRY       := MyMain
CC      := gcc
RM      := rm -f
INC     :=
ARM_FLAGS := -mlittle-endian -march=armv8-a+crc+simd+crypto+sb+predres -mtune=cortex-a72
LD_FLAGS    := -nostartfiles -e$(ENTRY)
GCC_FLAGS   := $(INC) -O2 -Wall -Wextra $(LD_FLAGS) $(ARM_FLAGS)
SRC = *.S *.c
.PHONY: all
all:
    @echo Building $(TARGET)..
    @$(CC) $(SRC) $(GCC_FLAGS) -o $(TARGET)
    @echo .. done
MyCFile.c
#include <stdio.h>
void foo(void)
{
    printf("ok");
    fflush(stout); // EDIT: adding this fixed the issue
}
Main.S
.global MyMain
.text
MyMain:
    bl foo      /* b: foo() is called infinitely. bl: foo() is never called [EDIT: fixed now with fflush ]*/
    MOV X0, 43 /* Return status of MyMain will be 43 */
    mov X8, 93 /* Syscall 93 = exit for this system */
    svc 0      /* Ask Linux to do its thing */
.data
