Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions runtime/druntime/src/core/thread/fiber/switch_context_riscv.S
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@
* Authors: Denis Feklushkin
*/

#if (__linux__ || __FreeBSD__ || __NetBSD__ || __OpenBSD__ || __DragonFly__) && __ELF__
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is the #if needed? Seems better to include this section for all targets.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the #if here and in the other two files

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about the other files. This functionality is perhaps only available for ELF and GCC ld (I read that lld ignores this section and defaults to noexecstack for all object files), so the #if ELF may make sense in the other files that are used for broader range of targets including non-ELF ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's see if #if __ELF__ is enough. I've added it to all three files since they are all part of the build, regardless of target. The riscv-specificity comes from the code being in an #if defined(__riscv)

/*
* Mark the resulting object file as not requiring execution permissions on
* stack memory. The absence of this section would mark the whole resulting
* library as requiring an executable stack, making it impossible to
* dynamically load druntime on several Linux platforms where this is
* forbidden due to security policies.
*/
.section .note.GNU-stack,"",%progbits
#endif


#if defined(__riscv)

// For save/load a register in memory, regardless of the size of machine register bit size
Expand Down
Loading