dangerous relocation warning by gcc

  Kiến thức lập trình

i have a copy_object function which basicly just makes a copy of any object given a pointer tp it and its size and i use it in a library i made
here is the function

/// @brief dynamically allocates a copy of an object
/// @param obj_ptr a pointer to the object
/// @param obj_size the size of the object
/// @return a pointer to the copy
extern void *copy_object(void *obj_ptr , size_t obj_size){
    void *copy = calloc(1 , obj_size);
    if(!copy){
        return NULL;
    }

    memcpy(copy , obj_ptr , obj_size);

    return copy;
}

when compiling the library on windows theres no proplem , but when i compile it on wsl unbuntu 22.04.3 with gcc version 11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04) i get this error :

/usr/bin/ld: BFD (GNU Binutils for Ubuntu) 2.38 assertion fail ../../bfd/reloc.c:8580
c_datastructures/bin//liblinked_list.a(copy_object.o):copy_object.c:(.pdata+0x0): dangerous relocation: collect2: fatal error: ld terminated with signal 11 [Segmentation fault]
compilation terminated.

i looked at the code as i have wrote it a long time ago but there’s no relocations in the first place it just copies memory

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT