authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-04-18 17:14:09-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-04-18 17:14:09-04:00
logca4341f7ba845e7af3c6f2be52cd60c51ec6d68f
tree683912e826b022abb51016f09b2d23b74c7ffed8
parentf1f998e07124f141312289ff82e0ad8d99af1cf7

add --no-rosegment cli option

this provides a workaround for #896 until valgrind adds support for clang/LLD (equivalent to gcc/gold -rosegment)

3 files changed, 10 insertions(+), 0 deletions(-)

src/all_types.hpp+2
...@@ -1705,6 +1705,8 @@ struct CodeGen {...@@ -1705,6 +1705,8 @@ struct CodeGen {
1705 ZigList<ZigLLVMDIType **> error_di_types;1705 ZigList<ZigLLVMDIType **> error_di_types;
17061706
1707 ZigList<Buf *> forbidden_libs;1707 ZigList<Buf *> forbidden_libs;
1708
1709 bool no_rosegment_workaround;
1708};1710};
17091711
1710enum VarLinkage {1712enum VarLinkage {
src/link.cpp+3
...@@ -217,6 +217,9 @@ static void construct_linker_job_elf(LinkJob *lj) {...@@ -217,6 +217,9 @@ static void construct_linker_job_elf(LinkJob *lj) {
217 lj->args.append(g->linker_script);217 lj->args.append(g->linker_script);
218 }218 }
219219
220 if (g->no_rosegment_workaround) {
221 lj->args.append("--no-rosegment");
222 }
220 lj->args.append("--gc-sections");223 lj->args.append("--gc-sections");
221224
222 lj->args.append("-m");225 lj->args.append("-m");
src/main.cpp+5
...@@ -74,6 +74,7 @@ static int usage(const char *arg0) {...@@ -74,6 +74,7 @@ static int usage(const char *arg0) {
74 " -L[dir] alias for --library-path\n"74 " -L[dir] alias for --library-path\n"
75 " -rdynamic add all symbols to the dynamic symbol table\n"75 " -rdynamic add all symbols to the dynamic symbol table\n"
76 " -rpath [path] add directory to the runtime library search path\n"76 " -rpath [path] add directory to the runtime library search path\n"
77 " --no-rosegment compromise security to workaround valgrind bug\n"
77 " -mconsole (windows) --subsystem console to the linker\n"78 " -mconsole (windows) --subsystem console to the linker\n"
78 " -mwindows (windows) --subsystem windows to the linker\n"79 " -mwindows (windows) --subsystem windows to the linker\n"
79 " -framework [name] (darwin) link against framework\n"80 " -framework [name] (darwin) link against framework\n"
...@@ -324,6 +325,7 @@ int main(int argc, char **argv) {...@@ -324,6 +325,7 @@ int main(int argc, char **argv) {
324 ZigList<const char *> test_exec_args = {0};325 ZigList<const char *> test_exec_args = {0};
325 int comptime_args_end = 0;326 int comptime_args_end = 0;
326 int runtime_args_start = argc;327 int runtime_args_start = argc;
328 bool no_rosegment_workaround = false;
327329
328 if (argc >= 2 && strcmp(argv[1], "build") == 0) {330 if (argc >= 2 && strcmp(argv[1], "build") == 0) {
329 const char *zig_exe_path = arg0;331 const char *zig_exe_path = arg0;
...@@ -507,6 +509,8 @@ int main(int argc, char **argv) {...@@ -507,6 +509,8 @@ int main(int argc, char **argv) {
507 mconsole = true;509 mconsole = true;
508 } else if (strcmp(arg, "-rdynamic") == 0) {510 } else if (strcmp(arg, "-rdynamic") == 0) {
509 rdynamic = true;511 rdynamic = true;
512 } else if (strcmp(arg, "--no-rosegment") == 0) {
513 no_rosegment_workaround = true;
510 } else if (strcmp(arg, "--each-lib-rpath") == 0) {514 } else if (strcmp(arg, "--each-lib-rpath") == 0) {
511 each_lib_rpath = true;515 each_lib_rpath = true;
512 } else if (strcmp(arg, "--enable-timing-info") == 0) {516 } else if (strcmp(arg, "--enable-timing-info") == 0) {
...@@ -844,6 +848,7 @@ int main(int argc, char **argv) {...@@ -844,6 +848,7 @@ int main(int argc, char **argv) {
844848
845 codegen_set_windows_subsystem(g, mwindows, mconsole);849 codegen_set_windows_subsystem(g, mwindows, mconsole);
846 codegen_set_rdynamic(g, rdynamic);850 codegen_set_rdynamic(g, rdynamic);
851 g->no_rosegment_workaround = no_rosegment_workaround;
847 if (mmacosx_version_min && mios_version_min) {852 if (mmacosx_version_min && mios_version_min) {
848 fprintf(stderr, "-mmacosx-version-min and -mios-version-min options not allowed together\n");853 fprintf(stderr, "-mmacosx-version-min and -mios-version-min options not allowed together\n");
849 return EXIT_FAILURE;854 return EXIT_FAILURE;