aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2026-03-16 08:46:11 +0100
committerFelix Morgner <felix.morgner@ost.ch>2026-03-16 08:46:11 +0100
commit81d1228cd0654d11efba13adb3ab7301d2b5ca49 (patch)
treeeb8c688b3091a9d5011d74e6b3c8d1265f3cdccd
parent408b499a47c8b4ad04bed8bb789583c721ce6955 (diff)
downloadteachos-81d1228cd0654d11efba13adb3ab7301d2b5ca49.tar.xz
teachos-81d1228cd0654d11efba13adb3ab7301d2b5ca49.zip
x86_64: remove stl_* sections for now
We currently don't really support user mode anymore, since it doesn't integrate well within the architecture. We therefore need no special handling of STL and kstd anymore.
-rw-r--r--arch/x86_64/scripts/kernel.ld20
-rw-r--r--libs/kstd/include/kstd/bits/shared_ptr.hpp15
-rw-r--r--libs/kstd/include/kstd/bits/unique_ptr.hpp12
-rw-r--r--libs/kstd/include/kstd/stack11
-rw-r--r--libs/kstd/include/kstd/vector31
-rw-r--r--libs/kstd/src/mutex.cpp5
6 files changed, 8 insertions, 86 deletions
diff --git a/arch/x86_64/scripts/kernel.ld b/arch/x86_64/scripts/kernel.ld
index 9a5dfd8..a429570 100644
--- a/arch/x86_64/scripts/kernel.ld
+++ b/arch/x86_64/scripts/kernel.ld
@@ -71,24 +71,24 @@ SECTIONS
.kernel_rodata ALIGN(4K) : AT (ADDR (.kernel_rodata) - TEACHOS_VMA)
{
- *(EXCLUDE_FILE (*libstdc++.a:*) .rodata*)
+ *(.rodata*)
} :kernel_rodata
.kernel_data ALIGN(4K) : AT (ADDR (.kernel_data) - TEACHOS_VMA)
{
- *(EXCLUDE_FILE (*libstdc++.a:*) .data*)
+ *(.data*)
} :kernel_data
. += 4K;
.kernel_bss ALIGN(4K) : AT (ADDR (.kernel_bss) - TEACHOS_VMA)
{
- *(EXCLUDE_FILE (*libstdc++.a:*) .stack .bss*)
+ *(.stack .bss*)
} :kernel_data
.kernel_text ALIGN(4K) : AT(ADDR (.kernel_text) - TEACHOS_VMA)
{
- *(EXCLUDE_FILE (*libstdc++.a:*) .text*)
+ *(.text*)
} :kernel_text
/***************************************************************************
@@ -97,28 +97,24 @@ SECTIONS
.user_rodata ALIGN(4K) : AT (ADDR (.user_rodata) - TEACHOS_VMA)
{
- *(.stl_rodata* .user_rodata*)
- KEEP(*libstdc++.a:*(.rodata*))
+ KEEP(*(.user_rodata*))
} :user_rodata
.user_data ALIGN(4K) : AT (ADDR (.user_data) - TEACHOS_VMA)
{
- *(.stl_data* .user_data*)
- KEEP(*libstdc++.a:*(.data*))
+ KEEP(*(.user_data*))
} :user_data
. += 4K;
.user_bss ALIGN(4K) : AT(ADDR (.user_bss) - TEACHOS_VMA)
{
- *(.stl_bss* .user_bss*)
- KEEP(*libstdc++.a:*(.bss*))
+ KEEP(*(.user_bss*))
} :user_data
.user_text ALIGN(4K) : AT(ADDR (.user_text) - TEACHOS_VMA)
{
- KEEP(*(.stl_text* .user_text*))
- KEEP(*libstdc++.a:*(.text*))
+ KEEP(*(.user_text*))
} :user_text
/***************************************************************************
diff --git a/libs/kstd/include/kstd/bits/shared_ptr.hpp b/libs/kstd/include/kstd/bits/shared_ptr.hpp
index 8caae3b..c57fa46 100644
--- a/libs/kstd/include/kstd/bits/shared_ptr.hpp
+++ b/libs/kstd/include/kstd/bits/shared_ptr.hpp
@@ -26,7 +26,6 @@ namespace kstd
*
* @param pointer A pointer to an object to manage (default is nullptr).
*/
- [[gnu::section(".stl_text")]]
explicit shared_ptr(T * pointer = nullptr)
: pointer(pointer)
, ref_count(new std::atomic<std::size_t>(pointer != nullptr ? 1 : 0))
@@ -39,7 +38,6 @@ namespace kstd
*
* @param other The shared_ptr to copy from.
*/
- [[gnu::section(".stl_text")]]
shared_ptr(shared_ptr const & other)
: pointer(other.pointer)
, ref_count(other.ref_count)
@@ -55,7 +53,6 @@ namespace kstd
*
* @param other The shared_ptr to move from.
*/
- [[gnu::section(".stl_text")]]
shared_ptr(shared_ptr && other) noexcept
: pointer(other.pointer)
, ref_count(other.ref_count)
@@ -72,7 +69,6 @@ namespace kstd
* @param other Another smart pointer to share the ownership with.
* @return Reference to this shared pointer.
*/
- [[gnu::section(".stl_text")]]
auto operator=(shared_ptr const & other) -> shared_ptr &
{
if (this != &other)
@@ -97,7 +93,6 @@ namespace kstd
* @param other Another smart pointer to acquire the ownership from.
* @return Reference to this shared pointer.
*/
- [[gnu::section(".stl_text")]]
auto operator=(shared_ptr && other) noexcept -> shared_ptr &
{
if (this != &other)
@@ -115,7 +110,6 @@ namespace kstd
/**
* @brief Destructor. Cleans up resources if necessary.
*/
- [[gnu::section(".stl_text")]]
~shared_ptr()
{
cleanup();
@@ -126,7 +120,6 @@ namespace kstd
*
* @param ptr Pointer to a new object to manage (default = nullptr).
*/
- [[gnu::section(".stl_text")]]
void reset(T * ptr = nullptr)
{
cleanup();
@@ -140,7 +133,6 @@ namespace kstd
*
* @param other The shared_ptr to swap with.
*/
- [[gnu::section(".stl_text")]]
void swap(shared_ptr & other)
{
std::swap(pointer, other.pointer);
@@ -152,7 +144,6 @@ namespace kstd
*
* @return Returns the object owned by *this, equivalent to *get().
*/
- [[gnu::section(".stl_text")]]
auto operator*() const -> T &
{
return *pointer;
@@ -163,7 +154,6 @@ namespace kstd
*
* @return Returns a pointer to the object owned by *this, i.e. get().
*/
- [[gnu::section(".stl_text")]]
auto operator->() const -> T *
{
return pointer;
@@ -174,7 +164,6 @@ namespace kstd
*
* @return Pointer to the managed object or nullptr if no object is owned.
*/
- [[gnu::section(".stl_text")]]
auto get() const -> T *
{
return pointer;
@@ -191,7 +180,6 @@ namespace kstd
* @return The number of Shared_pointer instances managing the current object or ​0​ if there is no managed
* object.
*/
- [[gnu::section(".stl_text")]]
auto use_count() const -> std::size_t
{
if (pointer != nullptr)
@@ -207,7 +195,6 @@ namespace kstd
*
* @return true if *this owns an object, false otherwise.
*/
- [[gnu::section(".stl_text")]]
explicit operator bool() const
{
return pointer != nullptr;
@@ -216,14 +203,12 @@ namespace kstd
/**
* @brief Defaulted three-way comparator operator.
*/
- [[gnu::section(".stl_text")]]
auto operator<=>(shared_ptr const & other) const = default;
private:
/**
* @brief Releases ownership and deletes the object if this was the last reference to the owned managed object.
*/
- [[gnu::section(".stl_text")]]
auto cleanup() -> void
{
if (pointer != nullptr && ref_count != nullptr && --(*ref_count) == 0)
diff --git a/libs/kstd/include/kstd/bits/unique_ptr.hpp b/libs/kstd/include/kstd/bits/unique_ptr.hpp
index 5f54848..f9a5a34 100644
--- a/libs/kstd/include/kstd/bits/unique_ptr.hpp
+++ b/libs/kstd/include/kstd/bits/unique_ptr.hpp
@@ -19,7 +19,6 @@ namespace kstd
*
* @param ptr A pointer to an object to manage (default is nullptr).
*/
- [[gnu::section(".stl_text")]]
explicit unique_ptr(T * ptr = nullptr)
: pointer(ptr)
{
@@ -29,7 +28,6 @@ namespace kstd
/**
* @brief Destructor that deletes the managed object.
*/
- [[gnu::section(".stl_text")]]
~unique_ptr()
{
delete pointer;
@@ -50,7 +48,6 @@ namespace kstd
*
* @param other Unique pointer to move from.
*/
- [[gnu::section(".stl_text")]]
unique_ptr(unique_ptr && other) noexcept
: pointer(other.pointer)
{
@@ -63,7 +60,6 @@ namespace kstd
* @param other Smart pointer from which ownership will be transferred.
* @return Reference to this unique pointer.
*/
- [[gnu::section(".stl_text")]]
auto operator=(unique_ptr && other) noexcept -> unique_ptr &
{
if (this != &other)
@@ -80,7 +76,6 @@ namespace kstd
*
* @return Returns the object owned by *this, equivalent to *get().
*/
- [[gnu::section(".stl_text")]]
auto operator*() const -> T &
{
return *pointer;
@@ -91,7 +86,6 @@ namespace kstd
*
* @return Returns a pointer to the object owned by *this, i.e. get().
*/
- [[gnu::section(".stl_text")]]
auto operator->() const -> T *
{
return pointer;
@@ -102,7 +96,6 @@ namespace kstd
*
* @return Pointer to the managed object or nullptr if no object is owned.
*/
- [[gnu::section(".stl_text")]]
auto get() const -> T *
{
return pointer;
@@ -113,7 +106,6 @@ namespace kstd
*
* @return true if *this owns an object, false otherwise.
*/
- [[gnu::section(".stl_text")]]
explicit operator bool() const noexcept
{
return pointer != nullptr;
@@ -127,7 +119,6 @@ namespace kstd
* @return Pointer to the managed object or nullptr if there was no managed object, i.e. the value which would be
* returned by get() before the call.
*/
- [[gnu::section(".stl_text")]]
auto release() -> T *
{
T * temp = pointer;
@@ -144,7 +135,6 @@ namespace kstd
*
* @param ptr Pointer to a new object to manage (default = nullptr).
*/
- [[gnu::section(".stl_text")]]
auto reset(T * ptr = nullptr) -> void
{
delete pointer;
@@ -156,7 +146,6 @@ namespace kstd
*
* @param other Another unique_ptr object to swap the managed object and the deleter with.
*/
- [[gnu::section(".stl_text")]]
auto swap(unique_ptr & other) -> void
{
using std::swap;
@@ -166,7 +155,6 @@ namespace kstd
/**
* @brief Defaulted three-way comparator operator.
*/
- [[gnu::section(".stl_text")]]
auto operator<=>(unique_ptr const & other) const = default;
private:
diff --git a/libs/kstd/include/kstd/stack b/libs/kstd/include/kstd/stack
index 8dc8e10..9750376 100644
--- a/libs/kstd/include/kstd/stack
+++ b/libs/kstd/include/kstd/stack
@@ -40,7 +40,6 @@ namespace kstd
* @param n Amount of elements we want to create and set the given value for.
* @param initial Inital value of all elements in the underlying data array.
*/
- [[gnu::section(".stl_text")]]
explicit stack(size_type n, value_type initial = value_type{})
: _container(n, initial)
{
@@ -55,7 +54,6 @@ namespace kstd
* @param last Input iterator to one past the last element in the range we want to copy from.
*/
template<typename InputIterator>
- [[gnu::section(".stl_text")]]
explicit stack(InputIterator first, InputIterator last)
: _container(first, last)
{
@@ -67,7 +65,6 @@ namespace kstd
*
* @param elements List we want to copy all elements from.
*/
- [[gnu::section(".stl_text")]]
explicit stack(std::initializer_list<T> elements)
: _container(elements)
{
@@ -82,7 +79,6 @@ namespace kstd
*
* @param other Other instance of stack we want to copy the data from.
*/
- [[gnu::section(".stl_text")]]
stack(stack<T> const & other)
: _container(other)
{
@@ -100,7 +96,6 @@ namespace kstd
*
* @return Current amount of elements.
*/
- [[gnu::section(".stl_text")]]
auto size() const -> size_type
{
return _container.size();
@@ -112,7 +107,6 @@ namespace kstd
*
* @return Reference to the last element.
*/
- [[gnu::section(".stl_text")]]
auto top() -> reference
{
return _container.back();
@@ -124,7 +118,6 @@ namespace kstd
*
* @return Reference to the last element.
*/
- [[gnu::section(".stl_text")]]
auto top() const -> const_reference
{
return _container.back();
@@ -143,7 +136,6 @@ namespace kstd
* @param value The value of the element to append.
*/
template<class U>
- [[gnu::section(".stl_text")]]
auto push(U && value) -> void
{
_container.push_back(std::forward<U>(value));
@@ -163,7 +155,6 @@ namespace kstd
* @return value_type&
*/
template<class... Args>
- [[gnu::section(".stl_text")]]
auto emplace(Args &&... args) -> reference
{
_container.emplace_back(std::forward<Args>(args)...);
@@ -176,7 +167,6 @@ namespace kstd
* further execution. Iterators and references to the last element are invalidated. The end()
* iterator is also invalidated.
*/
- [[gnu::section(".stl_text")]]
auto pop() -> void
{
_container.pop_back();
@@ -187,7 +177,6 @@ namespace kstd
*
* @return True if there are no elements, false if there are.
*/
- [[gnu::section(".stl_text")]]
auto empty() const -> bool
{
return _container.empty();
diff --git a/libs/kstd/include/kstd/vector b/libs/kstd/include/kstd/vector
index bbb2287..e0edf6a 100644
--- a/libs/kstd/include/kstd/vector
+++ b/libs/kstd/include/kstd/vector
@@ -99,7 +99,6 @@ namespace kstd
* @param other Other instance of vector we want to copy the data from.
* @return Newly created copy.
*/
- [[gnu::section(".stl_text")]]
auto operator=(vector const & other) -> vector<value_type> &
{
delete[] _data;
@@ -124,7 +123,6 @@ namespace kstd
*
* @return Current amount of elements.
*/
- [[gnu::section(".stl_text")]]
auto size() const -> size_type
{
return _size;
@@ -136,7 +134,6 @@ namespace kstd
*
* @return Current amount of space the vector has for elements.
*/
- [[gnu::section(".stl_text")]]
auto capacity() const -> size_type
{
return _capacity;
@@ -150,7 +147,6 @@ namespace kstd
* @param index Index we want to access elements at.
* @return Reference to the underlying element.
*/
- [[gnu::section(".stl_text")]]
auto operator[](size_type index) -> reference
{
return _data[index];
@@ -164,7 +160,6 @@ namespace kstd
* @param index Index we want to access elements at.
* @return Reference to the underlying element.
*/
- [[gnu::section(".stl_text")]]
auto operator[](size_type index) const -> const_reference
{
return _data[index];
@@ -178,7 +173,6 @@ namespace kstd
* @param index Index we want to access elements at.
* @return Reference to the underlying element.
*/
- [[gnu::section(".stl_text")]]
auto at(size_type index) -> reference
{
throw_if_out_of_range(index);
@@ -193,7 +187,6 @@ namespace kstd
* @param index Index we want to access elements at.
* @return Reference to the underlying element.
*/
- [[gnu::section(".stl_text")]]
auto at(size_type index) const -> const_reference
{
throw_if_out_of_range(index);
@@ -213,7 +206,6 @@ namespace kstd
* @param value The value of the element to append.
*/
template<class U>
- [[gnu::section(".stl_text")]]
auto push_back(U && value) -> void
{
increase_capacity_if_full();
@@ -235,7 +227,6 @@ namespace kstd
* @return value_type&
*/
template<class... Args>
- [[gnu::section(".stl_text")]]
auto emplace_back(Args &&... args) -> value_type &
{
increase_capacity_if_full();
@@ -249,7 +240,6 @@ namespace kstd
* further execution. Iterators and references to the last element are invalidated. The end()
* iterator is also invalidated.
*/
- [[gnu::section(".stl_text")]]
auto pop_back() -> void
{
throw_if_empty();
@@ -262,7 +252,6 @@ namespace kstd
*
* @return Iterator to the first element.
*/
- [[gnu::section(".stl_text")]]
auto begin() noexcept -> pointer
{
return _data;
@@ -274,7 +263,6 @@ namespace kstd
*
* @return Iterator to the first element.
*/
- [[gnu::section(".stl_text")]]
auto begin() const noexcept -> const_pointer
{
return _data;
@@ -286,7 +274,6 @@ namespace kstd
*
* @return Iterator to the first element.
*/
- [[gnu::section(".stl_text")]]
auto cbegin() const noexcept -> const_pointer
{
return begin();
@@ -298,7 +285,6 @@ namespace kstd
*
* @return Reverse iterator to the first element.
*/
- [[gnu::section(".stl_text")]]
auto rbegin() noexcept -> pointer
{
return _data + _size - 1;
@@ -310,7 +296,6 @@ namespace kstd
*
* @return Reverse iterator to the first element.
*/
- [[gnu::section(".stl_text")]]
auto rbegin() const noexcept -> const_pointer
{
return _data + _size - 1;
@@ -322,7 +307,6 @@ namespace kstd
*
* @return Reverse iterator to the first element.
*/
- [[gnu::section(".stl_text")]]
auto crbegin() const noexcept -> const_pointer
{
return rbegin();
@@ -334,7 +318,6 @@ namespace kstd
*
* @return Iterator to the element following the last element.
*/
- [[gnu::section(".stl_text")]]
auto end() noexcept -> pointer
{
return _data + _size;
@@ -346,7 +329,6 @@ namespace kstd
*
* @return Iterator to the element following the last element.
*/
- [[gnu::section(".stl_text")]]
auto end() const noexcept -> const_pointer
{
return _data + _size;
@@ -358,7 +340,6 @@ namespace kstd
*
* @return Iterator to the element following the last element.
*/
- [[gnu::section(".stl_text")]]
auto cend() const noexcept -> const_pointer
{
return end();
@@ -371,7 +352,6 @@ namespace kstd
*
* @return Reverse iterator to the element following the last element.
*/
- [[gnu::section(".stl_text")]]
auto rend() noexcept -> pointer
{
return _data + size() - 1;
@@ -384,7 +364,6 @@ namespace kstd
*
* @return Reverse iterator to the element following the last element.
*/
- [[gnu::section(".stl_text")]]
auto rend() const noexcept -> const_pointer
{
return _data + size() - 1;
@@ -397,7 +376,6 @@ namespace kstd
*
* @return Reverse iterator to the element following the last element.
*/
- [[gnu::section(".stl_text")]]
auto crend() const noexcept -> const_pointer
{
return rbegin();
@@ -411,7 +389,6 @@ namespace kstd
* @return Pointer to the underlying element storage. For non-empty containers, the returned pointer compares equal
* to the address of the first element.
*/
- [[gnu::section(".stl_text")]]
auto data() -> pointer
{
return _data;
@@ -425,7 +402,6 @@ namespace kstd
* @return Pointer to the underlying element storage. For non-empty containers, the returned pointer compares equal
* to the address of the first element.
*/
- [[gnu::section(".stl_text")]]
auto data() const -> const_pointer
{
return _data;
@@ -437,7 +413,6 @@ namespace kstd
*
* @return Reference to the first element.
*/
- [[gnu::section(".stl_text")]]
auto front() -> reference
{
throw_if_empty();
@@ -450,7 +425,6 @@ namespace kstd
*
* @return Reference to the first element.
*/
- [[gnu::section(".stl_text")]]
auto front() const -> const_reference
{
throw_if_empty();
@@ -463,7 +437,6 @@ namespace kstd
*
* @return Reference to the last element.
*/
- [[gnu::section(".stl_text")]]
auto back() -> reference
{
throw_if_empty();
@@ -476,7 +449,6 @@ namespace kstd
*
* @return Reference to the last element.
*/
- [[gnu::section(".stl_text")]]
auto back() const -> const_reference
{
throw_if_empty();
@@ -510,7 +482,6 @@ namespace kstd
*
* @param new_capacity New capacity of the vector, in number of elements
*/
- [[gnu::section(".stl_text")]]
auto reserve(size_type new_capacity) -> void
{
if (new_capacity <= _capacity)
@@ -531,7 +502,6 @@ namespace kstd
* If reallocation occurs, all iterators (including the end() iterator) and all references to the elements are
* invalidated. If no reallocation occurs, no iterators or references are invalidated.
*/
- [[gnu::section(".stl_text")]]
auto shrink_to_fit() -> void
{
if (_size == _capacity)
@@ -551,7 +521,6 @@ namespace kstd
*
* @return True if there are no elements, false if there are.
*/
- [[gnu::section(".stl_text")]]
auto empty() const -> bool
{
return _size <= 0;
diff --git a/libs/kstd/src/mutex.cpp b/libs/kstd/src/mutex.cpp
index cabf833..d66cb98 100644
--- a/libs/kstd/src/mutex.cpp
+++ b/libs/kstd/src/mutex.cpp
@@ -7,10 +7,8 @@
namespace kstd
{
- [[gnu::section(".stl_text")]]
mutex::mutex() = default;
- [[gnu::section(".stl_text")]]
mutex::~mutex()
{
if (m_locked.test(std::memory_order_relaxed))
@@ -19,7 +17,6 @@ namespace kstd
}
}
- [[gnu::section(".stl_text")]]
auto mutex::lock() -> void
{
while (!try_lock())
@@ -28,13 +25,11 @@ namespace kstd
}
}
- [[gnu::section(".stl_text")]]
auto mutex::try_lock() -> bool
{
return !m_locked.test_and_set(std::memory_order_acquire);
}
- [[gnu::section(".stl_text")]]
auto mutex::unlock() -> void
{
m_locked.clear(std::memory_order_release);