<commit_before># C Runtime Library

## Description

Modern compilers provide C runtime libraries designed to aid the compiler in
performing certain tasks (for GCC, this is the crtstuff.c in libgcc).
Three different functions that most of these libraries perform:
- Global Construction (executing functions defined in the ".ctors" and ".init_array" section)
- Global Destruction (executing functions defined in the ".dtors" and ".fini_array" section)
- Register Exception Framework Section (".eh_frame" section)

Although it is possible for the ELF loader to do these tasks for an executable,
from a security / containment perspective, it's better for the executable
itself to perform these task's in it's own isolated environment. Bareflank,
like everything else, needs to perform these same tasks, and thus performs
them in the context of the VMM, but can also use this code within a VM if
needed. For Bareflank, all of the C++ objects that are globally defined, have
constructors / destructors that need to be executed from a global perspective.
Each ".eh_frame" section in the ELF binary also needs to be registered with
the unwinder code to provide exception support.

## How It's Used

Each cross compiled shared library is compiled using the bareflank-gcc-wrapper.

[bareflank-gcc-wrapper](https://raw.githubusercontent.com/Bareflank/hypervisor/master/tools/scripts/bareflank-gcc-wrapper)

If you look at a GCC compiler (and even Clang/LLVM), both compilation
and linking is done with GCC. When linking is required, GCC calls LD (the
linker) on your behalf, and adds ctrbegin.o and crtend.o to your
executable (which it gets from crtstuff.c). These additional object files
provide the above described functionality. There are 4 different ELF sections
that need to be executed here:
- ctors<commit_msg>README.md: Corrected grammatical errors Signed-off-by: “Rico <“<EMAIL>”><commit_after># C Runtime Library

## Description

Modern compilers provide C runtime libraries designed to aid the compiler in
performing certain tasks (for GCC, this is the crtstuff.c in libgcc).
Three different functions that most of these libraries perform:
- Global Construction (executing functions defined in the ".ctors" and ".init_array" section)
- Global Destruction (executing functions defined in the ".dtors" and ".fini_array" section)
- Register Exception Framework Section (".eh_frame" section)

Although it is possible for the ELF loader to do these tasks for an executable,
from a security / containment perspective, it's better for the executable
itself to perform these tasks in its own isolated environment. Bareflank,
like everything else, needs to perform these same tasks, and thus performs
them in the context of the VMM, but can also use this code within a VM if
needed. For Bareflank, all of the C++ objects that are globally defined, have
constructors / destructors that need to be executed from a global perspective.
Each ".eh_frame" section in the ELF binary also needs to be registered with
the unwinder code to provide exception support.

## How It's Used

Each cross compiled shared library is compiled using the bareflank-gcc-wrapper.

[bareflank-gcc-wrapper](https://raw.githubusercontent.com/Bareflank/hypervisor/master/tools/scripts/bareflank-gcc-wrapper)

If you look at a GCC compiler (and even Clang/LLVM), both compilation
and linking is done with GCC. When linking is required, GCC calls LD (the
linker) on your behalf, and adds ctrbegin.o and crtend.o to your
executable (which it gets from crtstuff.c). These additional object files
provide the above described functionality. There are 4 different ELF sections
that need to be executed here:
- ctors
{'fraction_non_alphanumeric': 0.057749931898665216, 'fraction_numerical': 0.0005448106782892945, 'mean_word_length': 4.8471337579617835, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6461421', 'n_tokens_mistral': 991, 'n_tokens_neox': 928, 'n_words': 511}