Resguardo inicial

This commit is contained in:
lastdragon
2026-09-06 12:53:21 -06:00
parent 662efe3c2a
commit ad2088d178
94853 changed files with 43200404 additions and 0 deletions
@@ -0,0 +1,4 @@
# SPDX-License-Identifier: GPL-2.0-only
*.d
*.bin
*.output
+411
View File
@@ -0,0 +1,411 @@
# SPDX-License-Identifier: GPL-2.0
include ../../scripts/Makefile.include
LIBUNWIND_ARCHS:=aarch64 arm loongarch64 mips ppc32 ppc64 riscv s390x x86 x86_64
FILES= \
test-all.bin \
test-backtrace.bin \
test-bionic.bin \
test-libdw.bin \
test-eventfd.bin \
test-fortify-source.bin \
test-glibc.bin \
test-gtk2.bin \
test-gtk2-infobar.bin \
test-hello.bin \
test-libbfd.bin \
test-libbfd-threadsafe.bin \
test-disassembler-four-args.bin \
test-disassembler-init-styled.bin \
test-reallocarray.bin \
test-libbfd-liberty.bin \
test-libbfd-liberty-z.bin \
test-cplus-demangle.bin \
test-cxa-demangle.bin \
test-libcap.bin \
test-libelf.bin \
test-libelf-getphdrnum.bin \
test-libelf-gelf_getnote.bin \
test-libelf-getshdrstrndx.bin \
test-libelf-zstd.bin \
test-libdebuginfod.bin \
test-libnuma.bin \
test-numa_num_possible_cpus.bin \
test-libperl.bin \
test-libpython.bin \
test-libslang.bin \
test-libtraceevent.bin \
test-libcpupower.bin \
test-libtracefs.bin \
test-libunwind.bin \
test-libunwind-debug-frame.bin \
$(foreach arch,$(LIBUNWIND_ARCHS),test-libunwind-$(arch).bin test-libunwind-debug-frame-$(arch).bin) \
test-pthread-attr-setaffinity-np.bin \
test-pthread-barrier.bin \
test-stackprotector-all.bin \
test-timerfd.bin \
test-babeltrace2-ctf-writer.bin \
test-libcapstone.bin \
test-libcheck.bin \
test-compile-32.bin \
test-compile-x32.bin \
test-zlib.bin \
test-lzma.bin \
test-bpf.bin \
test-libbpf.bin \
test-sdt.bin \
test-cxx.bin \
test-gettid.bin \
test-jvmti.bin \
test-jvmti-cmlr.bin \
test-scandirat.bin \
test-sched_getcpu.bin \
test-setns.bin \
test-libopencsd.bin \
test-clang.bin \
test-llvm.bin \
test-llvm-perf.bin \
test-libaio.bin \
test-libzstd.bin \
test-clang-bpf-co-re.bin \
test-file-handle.bin \
test-libpfm4.bin \
test-rust.bin \
test-libopenssl.bin \
test-bpftool-skeletons.bin
FILES := $(addprefix $(OUTPUT),$(FILES))
# Some distros provide the command $(CROSS_COMPILE)pkg-config for
# searching packges installed with Multiarch. Use it for cross
# compilation if it is existed.
ifneq (, $(shell which $(CROSS_COMPILE)pkg-config))
PKG_CONFIG ?= $(CROSS_COMPILE)pkg-config
else
PKG_CONFIG ?= pkg-config
# PKG_CONFIG_PATH or PKG_CONFIG_LIBDIR, alongside PKG_CONFIG_SYSROOT_DIR
# for modified system root, are required for the cross compilation.
# If these PKG_CONFIG environment variables are not set, Multiarch library
# paths are used instead.
ifdef CROSS_COMPILE
ifeq ($(PKG_CONFIG_LIBDIR)$(PKG_CONFIG_PATH)$(PKG_CONFIG_SYSROOT_DIR),)
CROSS_ARCH = $(notdir $(CROSS_COMPILE:%-=%))
PKG_CONFIG_LIBDIR := /usr/local/$(CROSS_ARCH)/lib/pkgconfig/
PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/local/lib/$(CROSS_ARCH)/pkgconfig/
PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/lib/$(CROSS_ARCH)/pkgconfig/
PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/local/share/pkgconfig/
PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/share/pkgconfig/
export PKG_CONFIG_LIBDIR
endif
endif
endif
ifeq ($(findstring -static,${LDFLAGS}),-static)
PKG_CONFIG += --static
endif
all: $(FILES)
__BUILD = $(CC) $(CFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.c,$(@F)) $(LDFLAGS)
BUILD = $(__BUILD) > $(@:.bin=.make.output) 2>&1
BUILD_BFD = $(BUILD) -DPACKAGE='"perf"' -lbfd -ldl
BUILD_ALL = $(BUILD) -fstack-protector-all -O2 -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lelf -lslang \
$(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -ldl -lz -llzma -lzstd \
$(shell $(PKG_CONFIG) --libs --cflags openssl 2>/dev/null)
__BUILDXX = $(CXX) $(CXXFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.cpp,$(@F)) $(LDFLAGS)
BUILDXX = $(__BUILDXX) > $(@:.bin=.make.output) 2>&1
###############################
$(OUTPUT)test-all.bin:
$(BUILD_ALL)
$(OUTPUT)test-hello.bin:
$(BUILD)
$(OUTPUT)test-pthread-attr-setaffinity-np.bin:
$(BUILD) -D_GNU_SOURCE -lpthread
$(OUTPUT)test-pthread-barrier.bin:
$(BUILD) -lpthread
$(OUTPUT)test-stackprotector-all.bin:
$(BUILD) -fstack-protector-all
$(OUTPUT)test-fortify-source.bin:
$(BUILD) -O2 -D_FORTIFY_SOURCE=2
$(OUTPUT)test-bionic.bin:
$(BUILD)
$(OUTPUT)test-libcap.bin:
$(BUILD) -lcap
$(OUTPUT)test-libelf.bin:
$(BUILD) -lelf
$(OUTPUT)test-eventfd.bin:
$(BUILD)
$(OUTPUT)test-glibc.bin:
$(BUILD)
$(OUTPUT)test-scandirat.bin:
$(BUILD)
$(OUTPUT)test-sched_getcpu.bin:
$(BUILD)
$(OUTPUT)test-setns.bin:
$(BUILD)
$(OUTPUT)test-libopencsd.bin:
$(BUILD) # -lopencsd_c_api -lopencsd provided by
# $(FEATURE_CHECK_LDFLAGS-libopencsd)
DWLIBS := -ldw
ifeq ($(findstring -static,${LDFLAGS}),-static)
DWLIBS += -lelf -lz -llzma -lbz2 -lzstd
LIBDW_VERSION := $(shell $(PKG_CONFIG) --modversion libdw).0.0
LIBDW_VERSION_1 := $(word 1, $(subst ., ,$(LIBDW_VERSION)))
LIBDW_VERSION_2 := $(word 2, $(subst ., ,$(LIBDW_VERSION)))
# Elfutils merged libebl.a into libdw.a starting from version 0.177,
# Link libebl.a only if libdw is older than this version.
ifeq ($(shell test $(LIBDW_VERSION_2) -lt 177; echo $$?),0)
DWLIBS += -lebl
endif
# Must put -ldl after -lebl for dependency
DWARFLIBS += -ldl
endif
$(OUTPUT)test-libdw.bin:
$(BUILD) $(DWLIBS)
$(OUTPUT)test-libelf-getphdrnum.bin:
$(BUILD) -lelf
$(OUTPUT)test-libelf-gelf_getnote.bin:
$(BUILD) -lelf
$(OUTPUT)test-libelf-getshdrstrndx.bin:
$(BUILD) -lelf
$(OUTPUT)test-libelf-zstd.bin:
$(BUILD) -lelf -lz -lzstd
$(OUTPUT)test-libdebuginfod.bin:
$(BUILD) -ldebuginfod
$(OUTPUT)test-libnuma.bin:
$(BUILD) -lnuma
$(OUTPUT)test-numa_num_possible_cpus.bin:
$(BUILD) -lnuma
$(OUTPUT)test-libunwind.bin:
$(BUILD) -include libunwind.h -lelf -llzma -lunwind
$(OUTPUT)test-libunwind-debug-frame.bin:
$(BUILD) -include libunwind.h -lelf -llzma -lunwind
define LIBUNWIND_RULE
$$(OUTPUT)test-libunwind-$(1).bin:
$$(CC) $$(CFLAGS) -MD -Wall -Werror -include libunwind-$(1).h -o $$@ \
test-libunwind.c $$(LDFLAGS) -lelf -llzma -lunwind-$(1) \
> $$(@:.bin=.make.output) 2>&1
$$(OUTPUT)test-libunwind-debug-frame-$(1).bin:
$$(CC) $$(CFLAGS) -MD -Wall -Werror -include libunwind-$(1).h -o $$@ \
test-libunwind-debug-frame.c $$(LDFLAGS) -lelf -llzma -lunwind-$(1) \
> $$(@:.bin=.make.output) 2>&1
endef
$(foreach arch,$(LIBUNWIND_ARCHS), \
$(eval $(call LIBUNWIND_RULE,$(arch))) \
)
$(OUTPUT)test-libslang.bin:
$(BUILD) -lslang
$(OUTPUT)test-libtraceevent.bin:
$(BUILD) -ltraceevent
$(OUTPUT)test-libcpupower.bin:
$(BUILD) -lcpupower
$(OUTPUT)test-libtracefs.bin:
$(BUILD) $(shell $(PKG_CONFIG) --cflags libtracefs 2>/dev/null) -ltracefs
$(OUTPUT)test-gtk2.bin:
$(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null) -Wno-deprecated-declarations
$(OUTPUT)test-gtk2-infobar.bin:
$(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
grep-libs = $(filter -l%,$(1))
strip-libs = $(filter-out -l%,$(1))
PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
PERL_EMBED_CCOPTS = $(shell perl -MExtUtils::Embed -e ccopts 2>/dev/null)
FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
ifeq ($(CC_NO_CLANG), 0)
PERL_EMBED_LDOPTS := $(filter-out -specs=%,$(PERL_EMBED_LDOPTS))
PERL_EMBED_CCOPTS := $(filter-out -flto=auto -ffat-lto-objects, $(PERL_EMBED_CCOPTS))
PERL_EMBED_CCOPTS := $(filter-out -specs=%,$(PERL_EMBED_CCOPTS))
FLAGS_PERL_EMBED += -Wno-compound-token-split-by-macro
endif
$(OUTPUT)test-libperl.bin:
$(BUILD) $(FLAGS_PERL_EMBED)
$(OUTPUT)test-libpython.bin:
$(BUILD) $(FLAGS_PYTHON_EMBED)
$(OUTPUT)test-libbfd.bin:
$(BUILD_BFD)
$(OUTPUT)test-libbfd-threadsafe.bin:
$(BUILD_BFD) || $(BUILD_BFD) -liberty || $(BUILD_BFD) -liberty -lz
$(OUTPUT)test-disassembler-four-args.bin:
$(BUILD_BFD) -lopcodes || $(BUILD_BFD) -lopcodes -liberty || \
$(BUILD_BFD) -lopcodes -liberty -lz
$(OUTPUT)test-disassembler-init-styled.bin:
$(BUILD_BFD) -lopcodes || $(BUILD_BFD) -lopcodes -liberty || \
$(BUILD_BFD) -lopcodes -liberty -lz
$(OUTPUT)test-reallocarray.bin:
$(BUILD)
$(OUTPUT)test-libbfd-liberty.bin:
$(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty
$(OUTPUT)test-libbfd-liberty-z.bin:
$(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty -lz
$(OUTPUT)test-cplus-demangle.bin:
$(BUILD) -liberty
$(OUTPUT)test-cxa-demangle.bin:
$(BUILDXX)
$(OUTPUT)test-backtrace.bin:
$(BUILD)
$(OUTPUT)test-timerfd.bin:
$(BUILD)
$(OUTPUT)test-babeltrace2-ctf-writer.bin:
$(BUILD) # -lbabeltrace2-ctf-writer provided by $(FEATURE_CHECK_LDFLAGS-babeltrace2-ctf-writer)
$(OUTPUT)test-libcapstone.bin:
$(BUILD) # -lcapstone provided by $(FEATURE_CHECK_LDFLAGS-libcapstone)
$(OUTPUT)test-libcheck.bin:
$(BUILD) # -lcheck is provided by $(FEATURE_CHECK_LDFLAGS-libcheck)
$(OUTPUT)test-compile-32.bin:
$(CC) -m32 -Wall -Werror -o $@ test-compile.c
$(OUTPUT)test-compile-x32.bin:
$(CC) -mx32 -Wall -Werror -o $@ test-compile.c
$(OUTPUT)test-zlib.bin:
$(BUILD) -lz
$(OUTPUT)test-lzma.bin:
$(BUILD) -llzma
$(OUTPUT)test-bpf.bin:
$(BUILD)
$(OUTPUT)test-libbpf.bin:
$(BUILD) -lbpf
$(OUTPUT)test-sdt.bin:
$(BUILD)
$(OUTPUT)test-cxx.bin:
$(BUILDXX) -std=gnu++11
$(OUTPUT)test-gettid.bin:
$(BUILD)
$(OUTPUT)test-jvmti.bin:
$(BUILD)
$(OUTPUT)test-jvmti-cmlr.bin:
$(BUILD)
$(OUTPUT)test-llvm.bin:
$(BUILDXX) -std=gnu++17 \
-I$(shell $(LLVM_CONFIG) --includedir) \
-L$(shell $(LLVM_CONFIG) --libdir) \
$(shell $(LLVM_CONFIG) --libs Core BPF) \
$(shell $(LLVM_CONFIG) --system-libs) \
> $(@:.bin=.make.output) 2>&1
$(OUTPUT)test-llvm-perf.bin:
$(BUILDXX) -std=gnu++17 \
-I$(shell $(LLVM_CONFIG) --includedir) \
-L$(shell $(LLVM_CONFIG) --libdir) \
$(shell $(LLVM_CONFIG) --libs Core BPF) \
$(shell $(LLVM_CONFIG) --system-libs) \
> $(@:.bin=.make.output) 2>&1
$(OUTPUT)test-clang.bin:
$(BUILDXX) -std=gnu++17 \
-I$(shell $(LLVM_CONFIG) --includedir) \
-L$(shell $(LLVM_CONFIG) --libdir) \
-Wl,--start-group -lclang-cpp -Wl,--end-group \
$(shell $(LLVM_CONFIG) --libs Core option) \
$(shell $(LLVM_CONFIG) --system-libs) \
> $(@:.bin=.make.output) 2>&1
-include $(OUTPUT)*.d
$(OUTPUT)test-libaio.bin:
$(BUILD) -lrt
$(OUTPUT)test-libzstd.bin:
$(BUILD) -lzstd
$(OUTPUT)test-clang-bpf-co-re.bin: test-clang-bpf-co-re.c
{ $(CLANG) -S -g --target=bpf -o - $< | \
grep BTF_KIND_VAR; } > $(@:.bin=.make.output) 2>&1 && touch $@
$(OUTPUT)test-file-handle.bin:
$(BUILD)
$(OUTPUT)test-libpfm4.bin:
$(BUILD) -lpfm
$(OUTPUT)test-libopenssl.bin:
$(BUILD) $(shell $(PKG_CONFIG) --libs --cflags openssl 2>/dev/null)
$(OUTPUT)test-bpftool-skeletons.bin:
{ $(SYSTEM_BPFTOOL) version | grep '^features:.*skeletons'; } \
> $(@:.bin=.make.output) 2>&1 && touch $@
# Testing Rust is special: we don't compile anything, it's enough to check the
# compiler presence. Compiling a test code for this purposes is problematic,
# because Rust will emit a dependency file without any external references,
# meaning that if rustc will be removed the build process will still think it's
# there.
$(OUTPUT)test-rust.bin:
$(RUSTC) --version > /dev/null 2>&1
###############################
clean:
rm -f $(FILES) $(OUTPUT)*.d $(FILES:.bin=.make.output)
+183
View File
@@ -0,0 +1,183 @@
// SPDX-License-Identifier: GPL-2.0
/*
* test-all.c: Try to build all the main testcases at once.
*
* A well-configured system will have all the prereqs installed, so we can speed
* up auto-detection on such systems.
*/
/*
* Quirk: Python headers cannot be in arbitrary places, so keep this testcase at
* the top:
*/
#define main main_test_libpython
# include "test-libpython.c"
#undef main
#define main main_test_hello
# include "test-hello.c"
#undef main
#define main main_test_libelf
# include "test-libelf.c"
#undef main
#define main main_test_gettid
# include "test-gettid.c"
#undef main
#define main main_test_glibc
# include "test-glibc.c"
#undef main
#define main main_test_libdw
# include "test-libdw.c"
#undef main
#define main main_test_eventfd
# include "test-eventfd.c"
#undef main
#define main main_test_libelf_getphdrnum
# include "test-libelf-getphdrnum.c"
#undef main
#define main main_test_libelf_gelf_getnote
# include "test-libelf-gelf_getnote.c"
#undef main
#define main main_test_libelf_getshdrstrndx
# include "test-libelf-getshdrstrndx.c"
#undef main
#define main main_test_libelf_zstd
# include "test-libelf-zstd.c"
#undef main
#define main main_test_libslang
# include "test-libslang.c"
#undef main
#define main main_test_backtrace
# include "test-backtrace.c"
#undef main
#define main main_test_libnuma
# include "test-libnuma.c"
#undef main
#define main main_test_numa_num_possible_cpus
# include "test-numa_num_possible_cpus.c"
#undef main
#define main main_test_timerfd
# include "test-timerfd.c"
#undef main
#define main main_test_stackprotector_all
# include "test-stackprotector-all.c"
#undef main
#define main main_test_zlib
# include "test-zlib.c"
#undef main
#define main main_test_pthread_attr_setaffinity_np
# include "test-pthread-attr-setaffinity-np.c"
#undef main
#define main main_test_pthread_barrier
# include "test-pthread-barrier.c"
#undef main
#define main main_test_scandirat
# include "test-scandirat.c"
#undef main
#define main main_test_sched_getcpu
# include "test-sched_getcpu.c"
#undef main
# if 0
/*
* Disable babeltrace2-ctf-writer check for test-all, because the requested
* library version is not released yet in most distributions. Will
* reenable later.
*/
#define main main_test_babeltrace2_ctf_writer
# include "test-babeltrace2-ctf-writer.c"
#undef main
#endif
#define main main_test_lzma
# include "test-lzma.c"
#undef main
#define main main_test_bpf
# include "test-bpf.c"
#undef main
#define main main_test_sdt
# include "test-sdt.c"
#undef main
#define main main_test_setns
# include "test-setns.c"
#undef main
#define main main_test_libaio
# include "test-libaio.c"
#undef main
#define main main_test_reallocarray
# include "test-reallocarray.c"
#undef main
#define main main_test_libzstd
# include "test-libzstd.c"
#undef main
#define main main_test_libtraceevent
# include "test-libtraceevent.c"
#undef main
#define main main_test_libopenssl
# include "test-libopenssl.c"
#undef main
int main(int argc, char *argv[])
{
main_test_libpython();
main_test_hello();
main_test_libelf();
main_test_gettid();
main_test_glibc();
main_test_libdw();
main_test_eventfd();
main_test_libelf_getphdrnum();
main_test_libelf_gelf_getnote();
main_test_libelf_getshdrstrndx();
main_test_libslang();
main_test_backtrace();
main_test_libnuma();
main_test_numa_num_possible_cpus();
main_test_timerfd();
main_test_stackprotector_all();
main_test_zlib();
main_test_pthread_attr_setaffinity_np();
main_test_pthread_barrier();
main_test_lzma();
main_test_bpf();
main_test_scandirat();
main_test_sched_getcpu();
main_test_sdt();
main_test_setns();
main_test_libaio();
main_test_reallocarray();
main_test_libzstd();
main_test_libtraceevent();
main_test_libopenssl();
return 0;
}
@@ -0,0 +1,9 @@
// SPDX-License-Identifier: GPL-2.0
#include <babeltrace2-ctf-writer/writer.h>
int main(void)
{
bt_ctf_stream_class_get_packet_context_type((void *) 0);
return 0;
}
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: GPL-2.0
#include <execinfo.h>
#include <stdio.h>
int main(void)
{
void *backtrace_fns[10];
int entries;
entries = backtrace(backtrace_fns, 10);
backtrace_symbols_fd(backtrace_fns, entries, 1);
return 0;
}
@@ -0,0 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
#include <android/api-level.h>
int main(void)
{
return __ANDROID_API__;
}
@@ -0,0 +1,50 @@
// SPDX-License-Identifier: GPL-2.0
#include <asm/unistd.h>
#include <linux/bpf.h>
#include <unistd.h>
#ifndef __NR_bpf
# if defined(__i386__)
# define __NR_bpf 357
# elif defined(__x86_64__)
# define __NR_bpf 321
# elif defined(__aarch64__)
# define __NR_bpf 280
# elif defined(__sparc__)
# define __NR_bpf 349
# elif defined(__s390__)
# define __NR_bpf 351
# elif defined(__mips__) && defined(_ABIO32)
# define __NR_bpf 4355
# elif defined(__mips__) && defined(_ABIN32)
# define __NR_bpf 6319
# elif defined(__mips__) && defined(_ABI64)
# define __NR_bpf 5315
# elif defined(__loongarch__)
# define __NR_bpf 280
# else
# error __NR_bpf not defined. libbpf does not support your arch.
# endif
#endif
int main(void)
{
union bpf_attr attr;
/* Check fields in attr */
attr.prog_type = BPF_PROG_TYPE_KPROBE;
attr.insn_cnt = 0;
attr.insns = 0;
attr.license = 0;
attr.log_buf = 0;
attr.log_size = 0;
attr.log_level = 0;
attr.kern_version = 0;
attr.prog_flags = 0;
/*
* Test existence of __NR_bpf and BPF_PROG_LOAD.
* This call should fail if we run the testcase.
*/
return syscall(__NR_bpf, BPF_PROG_LOAD, &attr, sizeof(attr)) == 0;
}
@@ -0,0 +1,9 @@
// SPDX-License-Identifier: GPL-2.0
// Copyright (c) 2020 Facebook
struct test {
int a;
int b;
} __attribute__((preserve_access_index));
volatile struct test global_value_for_test = {};
@@ -0,0 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
#include <stdio.h>
int main(void)
{
printf("Hello World!\n");
return 0;
}
@@ -0,0 +1,15 @@
// SPDX-License-Identifier: GPL-2.0
extern int printf(const char *format, ...);
extern char *cplus_demangle(const char *, int);
int main(void)
{
char symbol[4096] = "FieldName__9ClassNameFd";
char *tmp;
tmp = cplus_demangle(symbol, 0);
printf("demangled symbol: {%s}\n", tmp);
return 0;
}
@@ -0,0 +1,17 @@
// SPDX-License-Identifier: GPL-2.0
#include <stdio.h>
#include <stdlib.h>
#include <cxxabi.h>
int main(void)
{
size_t len = 256;
char *output = (char*)malloc(len);
int status;
output = abi::__cxa_demangle("FieldName__9ClassNameFd", output, &len, &status);
printf("demangled symbol: {%s}\n", output);
return 0;
}
@@ -0,0 +1,15 @@
// SPDX-License-Identifier: GPL-2.0
#include <bfd.h>
#include <dis-asm.h>
int main(void)
{
bfd *abfd = bfd_openr(NULL, NULL);
disassembler(bfd_get_arch(abfd),
bfd_big_endian(abfd),
bfd_get_mach(abfd),
abfd);
return 0;
}
@@ -0,0 +1,13 @@
// SPDX-License-Identifier: GPL-2.0
#include <stdio.h>
#include <dis-asm.h>
int main(void)
{
struct disassemble_info info;
init_disassemble_info(&info, stdout,
NULL, NULL);
return 0;
}
@@ -0,0 +1,9 @@
// SPDX-License-Identifier: GPL-2.0
// Copyright (C) 2018, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
#include <sys/eventfd.h>
int main(void)
{
return eventfd(0, EFD_NONBLOCK);
}
@@ -0,0 +1,17 @@
#define _GNU_SOURCE
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <inttypes.h>
int main(void)
{
struct {
struct file_handle fh;
uint64_t cgroup_id;
} handle;
int mount_id;
name_to_handle_at(AT_FDCWD, "/", &handle.fh, &mount_id, 0);
return 0;
}
@@ -0,0 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
#include <stdio.h>
int main(void)
{
return puts("hi");
}
@@ -0,0 +1,11 @@
// SPDX-License-Identifier: GPL-2.0
// Copyright (C) 2019, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
#define _GNU_SOURCE
#include <unistd.h>
int main(void)
{
return gettid();
}
#undef _GNU_SOURCE
@@ -0,0 +1,20 @@
// SPDX-License-Identifier: GPL-2.0
#include <stdlib.h>
#if !defined(__UCLIBC__)
#include <gnu/libc-version.h>
#else
#define XSTR(s) STR(s)
#define STR(s) #s
#endif
int main(void)
{
#if !defined(__UCLIBC__)
const char *version = gnu_get_libc_version();
#else
const char *version = XSTR(__GLIBC__) "." XSTR(__GLIBC_MINOR__);
#endif
return version == NULL;
}
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: GPL-2.0
#pragma GCC diagnostic ignored "-Wstrict-prototypes"
#include <gtk/gtk.h>
#pragma GCC diagnostic error "-Wstrict-prototypes"
int main(int argc, char *argv[])
{
gtk_init(&argc, &argv);
gtk_info_bar_new();
return 0;
}
@@ -0,0 +1,11 @@
// SPDX-License-Identifier: GPL-2.0
#pragma GCC diagnostic ignored "-Wstrict-prototypes"
#include <gtk/gtk.h>
#pragma GCC diagnostic error "-Wstrict-prototypes"
int main(int argc, char *argv[])
{
gtk_init(&argc, &argv);
return 0;
}
@@ -0,0 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
#include <stdio.h>
int main(void)
{
return puts("hi");
}
@@ -0,0 +1,11 @@
// SPDX-License-Identifier: GPL-2.0
#include <jvmti.h>
#include <jvmticmlr.h>
int main(void)
{
jvmtiCompiledMethodLoadInlineRecord rec __attribute__((unused));
jvmtiCompiledMethodLoadRecordHeader hdr __attribute__((unused));
PCStackInfo p __attribute__((unused));
return 0;
}
@@ -0,0 +1,13 @@
// SPDX-License-Identifier: GPL-2.0
#include <jvmti.h>
int main(void)
{
JavaVM jvm __attribute__((unused));
jvmtiEventCallbacks cb __attribute__((unused));
jvmtiCapabilities caps __attribute__((unused));
jvmtiJlocationFormat format __attribute__((unused));
jvmtiEnv jvmti __attribute__((unused));
return 0;
}
@@ -0,0 +1,16 @@
// SPDX-License-Identifier: GPL-2.0
#include <aio.h>
int main(void)
{
struct aiocb aiocb;
aiocb.aio_fildes = 0;
aiocb.aio_offset = 0;
aiocb.aio_buf = 0;
aiocb.aio_nbytes = 0;
aiocb.aio_reqprio = 0;
aiocb.aio_sigevent.sigev_notify = 1 /*SIGEV_NONE*/;
return (int)aio_return(&aiocb);
}
@@ -0,0 +1,18 @@
// SPDX-License-Identifier: GPL-2.0
#include <bfd.h>
static bool lock(void *unused)
{
return true;
}
static bool unlock(void *unused)
{
return true;
}
int main(void)
{
/* Check for presence of new thread safety API (version 2.42) */
return !bfd_thread_init(lock, unlock, NULL);
}
@@ -0,0 +1,16 @@
// SPDX-License-Identifier: GPL-2.0
#include <bfd.h>
extern int printf(const char *format, ...);
int main(void)
{
char symbol[4096] = "FieldName__9ClassNameFd";
char *tmp;
tmp = bfd_demangle(0, symbol, 0);
printf("demangled symbol: {%s}\n", tmp);
return 0;
}
@@ -0,0 +1,11 @@
// SPDX-License-Identifier: GPL-2.0
#include <bpf/libbpf.h>
#if !defined(LIBBPF_MAJOR_VERSION) || (LIBBPF_MAJOR_VERSION < 1)
#error At least libbpf 1.0 is required for Linux tools.
#endif
int main(void)
{
return bpf_object__open("test") ? 0 : -1;
}
@@ -0,0 +1,20 @@
// SPDX-License-Identifier: GPL-2.0
#include <sys/capability.h>
#include <linux/capability.h>
int main(void)
{
cap_flag_value_t val;
cap_t caps = cap_get_proc();
if (!caps)
return 1;
if (cap_get_flag(caps, CAP_SYS_ADMIN, CAP_EFFECTIVE, &val) != 0)
return 1;
if (cap_free(caps) != 0)
return 1;
return 0;
}
@@ -0,0 +1,11 @@
// SPDX-License-Identifier: GPL-2.0
#include <capstone/capstone.h>
int main(void)
{
csh handle;
cs_open(CS_ARCH_X86, CS_MODE_64, &handle);
return 0;
}
@@ -0,0 +1,8 @@
// SPDX-License-Identifier: GPL-2.0
#include <check.h>
int main(void)
{
Suite *s = suite_create("test");
return s == 0;
}
@@ -0,0 +1,8 @@
// SPDX-License-Identifier: GPL-2.0
#include <cpuidle.h>
int main(void)
{
int rv = cpuidle_state_count(0);
return rv;
}
@@ -0,0 +1,8 @@
// SPDX-License-Identifier: GPL-2.0
#include <elfutils/debuginfod.h>
int main(void)
{
debuginfod_client* c = debuginfod_begin();
return !!c;
}
@@ -0,0 +1,56 @@
// SPDX-License-Identifier: GPL-2.0
#include <stdlib.h>
#include <dwarf.h>
#include <elfutils/libdw.h>
#include <elfutils/libdwfl.h>
#include <elfutils/version.h>
int test_libdw(void)
{
Dwarf *dbg = dwarf_begin(0, DWARF_C_READ);
return dbg == NULL;
}
int test_libdw_unwind(void)
{
/*
* This function is guarded via: __nonnull_attribute__ (1, 2).
* Passing '1' as arguments value. This code is never executed,
* only compiled.
*/
dwfl_thread_getframes((void *) 1, (void *) 1, NULL);
return 0;
}
int test_libdw_getlocations(void)
{
Dwarf_Addr base, start, end;
Dwarf_Attribute attr;
Dwarf_Op *op;
size_t nops;
ptrdiff_t offset = 0;
return (int)dwarf_getlocations(&attr, offset, &base, &start, &end, &op, &nops);
}
int test_libdw_getcfi(void)
{
Dwarf *dwarf = NULL;
return dwarf_getcfi(dwarf) == NULL;
}
int test_elfutils(void)
{
Dwarf_CFI *cfi = NULL;
dwarf_cfi_end(cfi);
return 0;
}
int main(void)
{
return test_libdw() + test_libdw_unwind() + test_libdw_getlocations() +
test_libdw_getcfi() + test_elfutils();
}
@@ -0,0 +1,8 @@
// SPDX-License-Identifier: GPL-2.0
#include <stdlib.h>
#include <gelf.h>
int main(void)
{
return gelf_getnote(NULL, 0, NULL, NULL, NULL) == 0;
}
@@ -0,0 +1,9 @@
// SPDX-License-Identifier: GPL-2.0
#include <libelf.h>
int main(void)
{
size_t dst;
return elf_getphdrnum(0, &dst);
}
@@ -0,0 +1,9 @@
// SPDX-License-Identifier: GPL-2.0
#include <libelf.h>
int main(void)
{
size_t dst;
return elf_getshdrstrndx(0, &dst);
}
@@ -0,0 +1,9 @@
// SPDX-License-Identifier: GPL-2.0
#include <stddef.h>
#include <libelf.h>
int main(void)
{
elf_compress(NULL, ELFCOMPRESS_ZSTD, 0);
return 0;
}
@@ -0,0 +1,9 @@
// SPDX-License-Identifier: GPL-2.0
#include <libelf.h>
int main(void)
{
Elf *elf = elf_begin(0, ELF_C_READ, 0);
return !!elf;
}
@@ -0,0 +1,10 @@
// SPDX-License-Identifier: GPL-2.0
#include <numa.h>
#include <numaif.h>
int main(void)
{
numa_available();
return 0;
}
@@ -0,0 +1,16 @@
// SPDX-License-Identifier: GPL-2.0
#include <opencsd/c_api/opencsd_c_api.h>
/*
* Check OpenCSD library version is sufficient to provide required features
*/
#define OCSD_MIN_VER ((1 << 16) | (2 << 8) | (1))
#if !defined(OCSD_VER_NUM) || (OCSD_VER_NUM < OCSD_MIN_VER)
#error "OpenCSD >= 1.2.1 is required"
#endif
int main(void)
{
(void)ocsd_get_version();
return 0;
}
@@ -0,0 +1,7 @@
#include <openssl/ssl.h>
#include <openssl/opensslv.h>
int main(void)
{
return SSL_library_init();
}
@@ -0,0 +1,10 @@
// SPDX-License-Identifier: GPL-2.0
#include <EXTERN.h>
#include <perl.h>
int main(void)
{
perl_alloc();
return 0;
}
@@ -0,0 +1,9 @@
// SPDX-License-Identifier: GPL-2.0
#include <sys/types.h>
#include <perfmon/pfmlib.h>
int main(void)
{
pfm_initialize();
return 0;
}
@@ -0,0 +1,10 @@
// SPDX-License-Identifier: GPL-2.0
#include <Python.h>
int main(void)
{
Py_Initialize();
return 0;
}
#undef _GNU_SOURCE
@@ -0,0 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
#include <slang.h>
int main(void)
{
return SLsmg_init_smg();
}
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: GPL-2.0
#include <trace-seq.h>
int main(void)
{
int rv = 0;
struct trace_seq s;
trace_seq_init(&s);
rv += !(s.state == TRACE_SEQ__GOOD);
trace_seq_destroy(&s);
return rv;
}
@@ -0,0 +1,10 @@
// SPDX-License-Identifier: GPL-2.0
#include <tracefs.h>
int main(void)
{
struct tracefs_instance *inst = tracefs_instance_create("dummy");
tracefs_instance_destroy(inst);
return 0;
}
@@ -0,0 +1,16 @@
// SPDX-License-Identifier: GPL-2.0
#include <stdlib.h>
extern int
UNW_OBJ(dwarf_find_debug_frame) (int found, unw_dyn_info_t *di_debug,
unw_word_t ip, unw_word_t segbase,
const char *obj_name, unw_word_t start,
unw_word_t end);
#define dwarf_find_debug_frame UNW_OBJ(dwarf_find_debug_frame)
int main(void)
{
dwarf_find_debug_frame(0, NULL, 0, 0, NULL, 0, 0);
return 0;
}
@@ -0,0 +1,27 @@
// SPDX-License-Identifier: GPL-2.0
#include <stdlib.h>
extern int UNW_OBJ(dwarf_search_unwind_table) (unw_addr_space_t as,
unw_word_t ip,
unw_dyn_info_t *di,
unw_proc_info_t *pi,
int need_unwind_info, void *arg);
#define dwarf_search_unwind_table UNW_OBJ(dwarf_search_unwind_table)
static unw_accessors_t accessors;
int main(void)
{
unw_addr_space_t addr_space;
addr_space = unw_create_addr_space(&accessors, 0);
if (addr_space)
return 0;
unw_init_remote(NULL, addr_space, NULL);
dwarf_search_unwind_table(addr_space, 0, NULL, NULL, 0, NULL);
return 0;
}
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: GPL-2.0
#include <zstd.h>
int main(void)
{
ZSTD_CStream *cstream;
cstream = ZSTD_createCStream();
ZSTD_freeCStream(cstream);
return 0;
}
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: GPL-2.0
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/raw_ostream.h"
#if LLVM_VERSION_MAJOR < 13
# error "Perf requires llvm-devel/llvm-dev version 13 or greater"
#endif
int main()
{
llvm::errs() << "Hello World!\n";
llvm::llvm_shutdown();
return 0;
}
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: GPL-2.0
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/raw_ostream.h"
#define NUM_VERSION (((LLVM_VERSION_MAJOR) << 16) + (LLVM_VERSION_MINOR << 8) + LLVM_VERSION_PATCH)
#if NUM_VERSION < 0x030900
# error "LLVM version too low"
#endif
int main()
{
llvm::errs() << "Hello World!\n";
llvm::llvm_shutdown();
return 0;
}
@@ -0,0 +1,11 @@
// SPDX-License-Identifier: GPL-2.0
#include <lzma.h>
int main(void)
{
lzma_stream strm = LZMA_STREAM_INIT;
lzma_ret ret;
ret = lzma_stream_decoder(&strm, UINT64_MAX, LZMA_CONCATENATED);
return ret ? -1 : 0;
}
@@ -0,0 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
#include <numa.h>
int main(void)
{
return numa_num_possible_cpus();
}
@@ -0,0 +1,18 @@
// SPDX-License-Identifier: GPL-2.0
#include <stdint.h>
#include <pthread.h>
#include <sched.h>
int main(void)
{
int ret = 0;
pthread_attr_t thread_attr;
cpu_set_t cs;
pthread_attr_init(&thread_attr);
CPU_ZERO(&cs);
ret = pthread_attr_setaffinity_np(&thread_attr, sizeof(cs), &cs);
return ret;
}
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: GPL-2.0
#include <stdint.h>
#include <pthread.h>
int main(void)
{
pthread_barrier_t barrier;
pthread_barrier_init(&barrier, NULL, 1);
pthread_barrier_wait(&barrier);
return pthread_barrier_destroy(&barrier);
}
@@ -0,0 +1,10 @@
// SPDX-License-Identifier: GPL-2.0
#define _GNU_SOURCE
#include <stdlib.h>
int main(void)
{
return !!reallocarray(NULL, 1, 1);
}
#undef _GNU_SOURCE
@@ -0,0 +1,13 @@
// SPDX-License-Identifier: GPL-2.0
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <dirent.h>
int main(void)
{
// expects non-NULL, arg3 is 'restrict' so "pointers" have to be different
return scandirat(/*dirfd=*/ 0, /*dirp=*/ (void *)1, /*namelist=*/ (void *)2, /*filter=*/ (void *)3, /*compar=*/ (void *)4);
}
#undef _GNU_SOURCE
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: GPL-2.0
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <sched.h>
int main(void)
{
return sched_getcpu();
}
#undef _GNU_SOURCE
@@ -0,0 +1,8 @@
// SPDX-License-Identifier: GPL-2.0
#include <sys/sdt.h>
int main(void)
{
DTRACE_PROBE(provider, name);
return 0;
}
@@ -0,0 +1,9 @@
// SPDX-License-Identifier: GPL-2.0
#define _GNU_SOURCE
#include <sched.h>
int main(void)
{
return setns(0, 0);
}
#undef _GNU_SOURCE
@@ -0,0 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
#include <stdio.h>
int main(void)
{
return puts("hi");
}
@@ -0,0 +1,19 @@
// SPDX-License-Identifier: GPL-2.0
/*
* test for timerfd functions used by perf-kvm-stat-live
*/
#include <sys/timerfd.h>
int main(void)
{
struct itimerspec new_value;
int fd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK);
if (fd < 0)
return 1;
if (timerfd_settime(fd, 0, &new_value, NULL) != 0)
return 1;
return 0;
}
@@ -0,0 +1,10 @@
// SPDX-License-Identifier: GPL-2.0
#include <zlib.h>
int main(void)
{
z_stream zs;
inflateInit(&zs);
return 0;
}