Skip to content

Commit

Permalink
add --no-rosegment cli option
Browse files Browse the repository at this point in the history
this provides a workaround for #896
until valgrind adds support for clang/LLD
(equivalent to gcc/gold -rosegment)
  • Loading branch information
andrewrk committed Apr 18, 2018
1 parent f1f998e commit ca4341f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/all_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1705,6 +1705,8 @@ struct CodeGen {
ZigList<ZigLLVMDIType **> error_di_types;

ZigList<Buf *> forbidden_libs;

bool no_rosegment_workaround;
};

enum VarLinkage {
Expand Down
3 changes: 3 additions & 0 deletions src/link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ static void construct_linker_job_elf(LinkJob *lj) {
lj->args.append(g->linker_script);
}

if (g->no_rosegment_workaround) {
lj->args.append("--no-rosegment");
}
lj->args.append("--gc-sections");

lj->args.append("-m");
Expand Down
5 changes: 5 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ static int usage(const char *arg0) {
" -L[dir] alias for --library-path\n"
" -rdynamic add all symbols to the dynamic symbol table\n"
" -rpath [path] add directory to the runtime library search path\n"
" --no-rosegment compromise security to workaround valgrind bug\n"
" -mconsole (windows) --subsystem console to the linker\n"
" -mwindows (windows) --subsystem windows to the linker\n"
" -framework [name] (darwin) link against framework\n"
Expand Down Expand Up @@ -324,6 +325,7 @@ int main(int argc, char **argv) {
ZigList<const char *> test_exec_args = {0};
int comptime_args_end = 0;
int runtime_args_start = argc;
bool no_rosegment_workaround = false;

if (argc >= 2 && strcmp(argv[1], "build") == 0) {
const char *zig_exe_path = arg0;
Expand Down Expand Up @@ -507,6 +509,8 @@ int main(int argc, char **argv) {
mconsole = true;
} else if (strcmp(arg, "-rdynamic") == 0) {
rdynamic = true;
} else if (strcmp(arg, "--no-rosegment") == 0) {
no_rosegment_workaround = true;
} else if (strcmp(arg, "--each-lib-rpath") == 0) {
each_lib_rpath = true;
} else if (strcmp(arg, "--enable-timing-info") == 0) {
Expand Down Expand Up @@ -844,6 +848,7 @@ int main(int argc, char **argv) {

codegen_set_windows_subsystem(g, mwindows, mconsole);
codegen_set_rdynamic(g, rdynamic);
g->no_rosegment_workaround = no_rosegment_workaround;
if (mmacosx_version_min && mios_version_min) {
fprintf(stderr, "-mmacosx-version-min and -mios-version-min options not allowed together\n");
return EXIT_FAILURE;
Expand Down

0 comments on commit ca4341f

Please sign in to comment.