|
71 | 71 |
|
72 | 72 | #endif |
73 | 73 |
|
| 74 | +#if defined(__aarch64__) && defined(__ELF__) && \ |
| 75 | + defined(COMPILER_RT_EXECUTE_ONLY_CODE) |
| 76 | +// The assembler always creates an implicit '.text' section with default flags |
| 77 | +// (SHF_ALLOC | SHF_EXECINSTR), which is incompatible with the execute-only |
| 78 | +// '.text' section we want to create here because of the missing |
| 79 | +// SHF_AARCH64_PURECODE section flag. To solve this, we use 'unique,0' to |
| 80 | +// differentiate the two sections. The output will therefore have two separate |
| 81 | +// sections named '.text', where code will be placed into the execute-only |
| 82 | +// '.text' section, and the implicitly-created one will be empty. |
| 83 | +#define TEXT_SECTION \ |
| 84 | + .section .text,"axy",@progbits,unique,0 |
| 85 | +#else |
| 86 | +#define TEXT_SECTION \ |
| 87 | + .text |
| 88 | +#endif |
| 89 | + |
74 | 90 | #if defined(__arm__) || defined(__aarch64__) || defined(__arm64ec__) |
75 | 91 | #define FUNC_ALIGN \ |
76 | | - .text SEPARATOR \ |
77 | 92 | .balign 16 SEPARATOR |
78 | 93 | #else |
79 | 94 | #define FUNC_ALIGN |
|
255 | 270 | #endif |
256 | 271 |
|
257 | 272 | #define DEFINE_COMPILERRT_FUNCTION(name) \ |
| 273 | + TEXT_SECTION SEPARATOR \ |
258 | 274 | DEFINE_CODE_STATE \ |
259 | 275 | FILE_LEVEL_DIRECTIVE SEPARATOR \ |
260 | 276 | .globl FUNC_SYMBOL(SYMBOL_NAME(name)) SEPARATOR \ |
|
264 | 280 | FUNC_SYMBOL(SYMBOL_NAME(name)): |
265 | 281 |
|
266 | 282 | #define DEFINE_COMPILERRT_THUMB_FUNCTION(name) \ |
| 283 | + TEXT_SECTION SEPARATOR \ |
267 | 284 | DEFINE_CODE_STATE \ |
268 | 285 | FILE_LEVEL_DIRECTIVE SEPARATOR \ |
269 | 286 | .globl FUNC_SYMBOL(SYMBOL_NAME(name)) SEPARATOR \ |
|
273 | 290 | FUNC_SYMBOL(SYMBOL_NAME(name)): |
274 | 291 |
|
275 | 292 | #define DEFINE_COMPILERRT_PRIVATE_FUNCTION(name) \ |
| 293 | + TEXT_SECTION SEPARATOR \ |
276 | 294 | DEFINE_CODE_STATE \ |
277 | 295 | FILE_LEVEL_DIRECTIVE SEPARATOR \ |
278 | 296 | .globl FUNC_SYMBOL(SYMBOL_NAME(name)) SEPARATOR \ |
|
282 | 300 | FUNC_SYMBOL(SYMBOL_NAME(name)): |
283 | 301 |
|
284 | 302 | #define DEFINE_COMPILERRT_PRIVATE_FUNCTION_UNMANGLED(name) \ |
| 303 | + TEXT_SECTION SEPARATOR \ |
285 | 304 | DEFINE_CODE_STATE \ |
286 | 305 | .globl FUNC_SYMBOL(name) SEPARATOR \ |
287 | 306 | SYMBOL_IS_FUNC(name) SEPARATOR \ |
|
290 | 309 | FUNC_SYMBOL(name): |
291 | 310 |
|
292 | 311 | #define DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(name) \ |
| 312 | + TEXT_SECTION SEPARATOR \ |
293 | 313 | DEFINE_CODE_STATE \ |
294 | 314 | FUNC_ALIGN \ |
295 | 315 | .globl FUNC_SYMBOL(name) SEPARATOR \ |
|
0 commit comments