RFC: Re: MachO ARM assembly, why does the .set directive emit a NoDeadStrip symbol attribute for the symbol being defined?

Given the following ARM asm source:

.syntax unified

.p2align 2


.section .text.bar,”ax”,%progbits

.globl bar

.type bar, %function



mov r3, r1

mov r1, r2

mov r2, r3

bl memset

.globl foo

.type foo, %function

.set foo, bar

Note that when the file is assembled for MachO, the llvm back-end will set the NoDeadStrip flag on the symbol “foo”.

This will cause the section that foo is defined in (.text.bar) to be retained in a link in which the assembled object file is a part, even if neither “foo” nor “bar” are referenced elsewhere in the linked application.

Why does the .set directive behave this way for MachO when there is an explicit asm directive, “.no_dead_strip,” available to be used in assembly source?

~ Todd Snider