Cannot add `libc.so.6` to LLJIT

I’m writing a JIT compiler like Kaleidoscope, but I’d like to use llvm::orc::LLJIT.

llvm::orc::LLJIT has addObjectFile() as a member function. I tried to add /usr/lib/libc.so.6 to call printf() in the JIT, but it failed.

Here is my code:

#include <iostream>
#include <memory>

#include "llvm/Support/TargetSelect.h"
#include "llvm/ExecutionEngine/Orc/LLJIT.h"

int main(){
	// Initialize JIT (LLJIT)
	llvm::InitializeNativeTarget();
	std::unique_ptr<llvm::orc::LLJIT> jit = std::move(llvm::orc::LLJITBuilder().create().get());

	// libc.so is here
	char filename[] = "/usr/lib/libc.so.6";

	// Read to buffer
	llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> error_or_buffer = llvm::MemoryBuffer::getFile(filename);
	if(!error_or_buffer){
		std::cerr << "failed to open " << filename << ": " << error_or_buffer.getError().message() << std::endl;
		return -1;
	}

	// Add to JIT
	if(llvm::Error error = jit->addObjectFile(std::move(error_or_buffer.get()))){
		std::cerr << "failed to add " << filename << " to LLJIT" << std::endl;
		llvm::errs() << error << '\n';
		return -1;
	}
}

I compiled it with clang++, ran and got an error:

$ clang++ main.cpp -lLLVM
$ ./a.out
failed to add /usr/lib/libc.so.6 to LLJIT
Duplicate definition of symbol '__cxa_atexit'

When I changed my code and added libm.so.6 to jit instead of libc.so.6, it ran with no error.

Is there any problem with libc.so.6?

Versions of the tools:

$ llvm-config --version
13.0.0
$ clang++ --version
clang version 13.0.0
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
$ /lib/libc.so.6
GNU C Library (GNU libc) release release version 2.33.
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 11.1.0.
libc ABIs: UNIQUE IFUNC ABSOLUTE
For bug reporting instructions, please see:
<https://bugs.archlinux.org/>.