1
0
mirror of https://github.com/ohwgiles/laminar.git synced 2024-10-27 20:34:20 +00:00

Link binary resources rodata with GNU-stack note

Improve the linking of binary resources so the content is in .rodata
and the object contains a read-only flagged GNU-stack note. This causes
GNU ld to not mark the stack executable in the final binary.

Resolves #55
This commit is contained in:
Oliver Giles 2018-06-23 14:36:31 +03:00
parent 2a14567b79
commit b1dc0d62a0

View File

@ -43,7 +43,11 @@ macro(generate_compressed_bins BASEDIR)
DEPENDS ${BASEDIR}/${FILE} DEPENDS ${BASEDIR}/${FILE}
) )
add_custom_command(OUTPUT ${OUTPUT_FILE} add_custom_command(OUTPUT ${OUTPUT_FILE}
COMMAND ld -r -b binary -o ${OUTPUT_FILE} ${COMPRESSED_FILE} COMMAND ${CMAKE_LINKER} -r -b binary -o ${OUTPUT_FILE} ${COMPRESSED_FILE}
COMMAND ${CMAKE_OBJCOPY}
--rename-section .data=.rodata.alloc,load,readonly,data,contents
--add-section .note.GNU-stack=/dev/null
--set-section-flags .note.GNU-stack=contents,readonly ${OUTPUT_FILE}
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${COMPRESSED_FILE} DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${COMPRESSED_FILE}
) )
list(APPEND COMPRESSED_BINS ${OUTPUT_FILE}) list(APPEND COMPRESSED_BINS ${OUTPUT_FILE})