In Chapter 5.5, there is one step that fixes the GCC's stack protection detection problem. The command is:

sed -i '/k prot/agcc_cv_libc_provides_ssp=yes' gcc/configure

This command seems weird to me at first glance. After digging a little more about sed command, it's intention is much clear.

  • -i means change the file (i.e., gcc/configure) in place

  • /k prot/ is the pattern. If you look at gcc/configure, you'll find a line (around 26695) of comment that says:

# Test for stack protector support in target C library

And you'll see that this is the only occurrence of "stack protector" (as well as k prot. I think we'd better use /stack protector/ as the pattern for easy understanding.

  • a means append a line after the line that contains the pattern. (sed document)

  • gcc_cv_libc_provides_ssp=yes is the actual line being appended.