Fixes #61355. The __dso_handle decl was introduced incorrectly into the startup objects during the integration test cleanup which moved the integration tests away from using an artificial sysroot to using -nostdlib. Having it in the startup creates the duplicate symbol error when one does not use -nostdlib. Since this is an integration test only problem, it is meaningful to keep it in the integration test anyway. Differential Revision: https://reviews.llvm.org/D145898
41 lines
1.2 KiB
C++
41 lines
1.2 KiB
C++
//===-- Simple malloc and free for use with integration tests -------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
// Integration tests cannot use the SCUDO standalone allocator as SCUDO pulls
|
|
// various other parts of the libc. Since SCUDO development does not use
|
|
// LLVM libc build rules, it is very hard to keep track or pull all that SCUDO
|
|
// requires. Hence, as a work around for this problem, we use a simple allocator
|
|
// which just hands out continuous blocks from a statically allocated chunk of
|
|
// memory.
|
|
|
|
static uint8_t memory[16384];
|
|
static uint8_t *ptr = memory;
|
|
|
|
extern "C" {
|
|
|
|
void *malloc(size_t s) {
|
|
void *mem = ptr;
|
|
ptr += s;
|
|
return mem;
|
|
}
|
|
|
|
void free(void *) {}
|
|
|
|
void *realloc(void *ptr, size_t s) {
|
|
free(ptr);
|
|
return malloc(s);
|
|
}
|
|
|
|
// Integration tests are linked with -nostdlib. BFD linker expects
|
|
// __dso_handle when -nostdlib is used.
|
|
void *__dso_handle = nullptr;
|
|
} // extern "C"
|