toge's diary

コンピュータ関連の趣味をつらつらと。

gccでExec-Shield無効バイナリを生成する

gccでコンパイルしたバイナリが、デフォルトでExec-Shieldが有効になっているのが面倒だな。
コンパイルオプションとかで無効に出来ないんだろうか?
べつにMakefileni"-execstack -s"を追加するだけでもいいんですけどね。

調べてみるとLinkerの機能にありますね。

 -z execstack          Mark executable as requiring executable stack
 -z noexecstack        Mark executable as not requiring executable stack 

ということで以下のようにするといいらしい。-Xlinkerはトークンごとに指定しないといけないので注意。

% g++ -L. -o SoftWire Test.o -lSoftWire -Xlinker -z -Xlinker execstack
% execstack -q ./SoftWire
X ./SoftWire