Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unknown section type: %progbits #65

Closed
VeXocide opened this issue Aug 7, 2013 · 8 comments
Closed

unknown section type: %progbits #65

VeXocide opened this issue Aug 7, 2013 · 8 comments

Comments

@VeXocide
Copy link
Contributor

VeXocide commented Aug 7, 2013

The stack markings introduced in #60 lead to a compilation failure on OS X 10.8 using GCC 4.7 from MacPorts, with the following error:

  CCAS     crypto_stream/salsa20/amd64_xmm6/stream_salsa20_amd64_xmm6.lo
crypto_stream/salsa20/amd64_xmm6/stream_salsa20_amd64_xmm6.s:949:unknown section type: %progbits

This is rather odd given it's wrapped in an #if as follows:

#if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits
#endif

Neither of the two defined hold true.

@jedisct1
Copy link
Owner

jedisct1 commented Aug 7, 2013

Duh? This is indeed super weird.
So, preprocessor directives are blindly ignored in asm code when using this compiler? Wow. Crap.

We can work around it using autoconf magic, but this is pretty annoying.

@VeXocide
Copy link
Contributor Author

VeXocide commented Aug 7, 2013

http://www.gentoo.org/proj/en/hardened/gnu-stack.xml#doc_chap6 lists a second alternative, compiling with --noexecstack.

@jedisct1
Copy link
Owner

jedisct1 commented Aug 7, 2013

That sounds like a better option. Still.. #if statements not working is worrying.

Can anybody running Gentoo check that the --nonexecstack option actually works as expected?

@VeXocide
Copy link
Contributor Author

VeXocide commented Aug 7, 2013

The relevant command from make -n is:

echo "  CCAS    " crypto_stream/salsa20/amd64_xmm6/stream_salsa20_amd64_xmm6.lo;/bin/sh ../../libtool --silent   --mode=compile /opt/local/bin/gcc-mp-4.7 -std=gnu99  -g -O2 -c -o crypto_stream/salsa20/amd64_xmm6/stream_salsa20_amd64_xmm6.lo crypto_stream/salsa20/amd64_xmm6/stream_salsa20_amd64_xmm6.s

Now it turns out there's the following subtlety, from http://stackoverflow.com/a/7190511:

  • If the file name ends with ".s" (lowercase 's'), then gcc calls the assembler.
  • If the file name ends with ".S" (uppercase 'S'), then gcc applies the C preprocessor on the source file (i.e. it recognizes directives such as #if and replaces macros), and then calls the assembler on the result.

Thus we want to call gcc as follows to solve the problem:

gcc -S file.c -o file.s
gcc -c file.s

Still, the --nonexecstack might be the better option in this particular case.

@jedisct1
Copy link
Owner

jedisct1 commented Aug 7, 2013

Good catch. Hope it will work on case-insensitive filesystems as well. Let's give it a shot.

@jedisct1
Copy link
Owner

jedisct1 commented Aug 7, 2013

Can you try with the current git master?

@VeXocide
Copy link
Contributor Author

VeXocide commented Aug 7, 2013

It compiles as expected, fixed!

@jedisct1
Copy link
Owner

jedisct1 commented Aug 7, 2013

Neat! And good to know!

Thanks a lot for your report!

@jedisct1 jedisct1 closed this as completed Aug 7, 2013
Repository owner locked and limited conversation to collaborators Aug 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants