I am currently making a library which overrides certain libC functions (such as strcpy).
The problem is when I call one of these functions which in its code call another function (which may be in LibC), it calls LibC's instead of the other one currently in library.
Example:
The instruction call strcpy WRT ..plt will call LibC's strcpy instead of mine present in the Shared Object file.
How can I make it so it calls in priority the function from my own library instead of LibC's ?
Edit:
Here is a minimal testable example:
memmove.asm
bits 64
    global memmove:function
    extern malloc
    extern memcpy
    extern free
    section .text:
    ; void *memmove(void *dest, const void *src, size_t n)
memmove:
    ; RDI = dest
    ; RSI = src
    ; RDX = n
    push rdi    ; RSP + 0x10
    push rsi    ; RSP + 0x8
    push rdx    ; RSP
    mov rdi, [rsp]  ; n (Restore RDX)
    call malloc WRT ..plt
    mov rdi, rax    ; dest
    mov rsi, [rsp + 0x8]    ; src (Restore RSI)
    mov rdx, [rsp]  ; n (Restore RDX)
    call memcpy WRT ..plt
    mov rdi, [rsp + 0x10]   ; dest (Restore RDI)
    mov rsi, rax
    mov rdx, [rsp]
    ;push rax
    call memcpy WRT ..plt
    ;pop rdi
    ;call free WRT ..plt
    pop rdx
    pop rsi
    pop rdi
    ret
memcpy.asm
    bits 64
    global memcpy:function
    section .text:
    ; void *memcpy(void *dest, const void *src, size_t n)
memcpy:
    ; RDI = dest
    ; RSI = src
    ; RDX = n
    xor rcx, rcx
    .loop_begin:
    cmp rcx, rdx
    je short .loop_end
    mov r9b, BYTE [rsi + rcx]
    mov BYTE [rdi + rcx], r9b
    inc rcx
    jmp short .loop_begin
    .loop_end:
    mov rax, rdi
    ret
