diff --git a/node.gypi b/node.gypi index e6f5872cc75460..a83c63e23da7f7 100644 --- a/node.gypi +++ b/node.gypi @@ -306,22 +306,6 @@ 'ldflags': [ '-Wl,-z,relro', '-Wl,-z,now' ] }], - [ 'OS=="linux" and ' - 'target_arch=="x64" and ' - 'llvm_version=="0.0"', { - 'ldflags': [ - '-Wl,-T', - '> std::hex >> start; @@ -136,26 +129,42 @@ static struct text_region FindNodeTextRegion() { iss >> offset; iss >> dev; iss >> inode; - if (inode != 0) { - std::string pathname; - iss >> pathname; - if (pathname == exename && permission == "r-xp") { - uintptr_t ntext = reinterpret_cast(&__nodetext); - if (ntext >= start && ntext < end) { - char* from = reinterpret_cast(hugepage_align_up(ntext)); - char* to = reinterpret_cast(hugepage_align_down(end)); - - if (from < to) { - size_t size = to - from; - nregion.found_text_region = true; - nregion.from = from; - nregion.to = to; - nregion.total_hugepages = size / hps; - } - break; - } - } - } + + if (inode == 0) + continue; + + std::string pathname; + iss >> pathname; + + if (start != reinterpret_cast(&__executable_start)) + continue; + + // The next line is our .text section. + if (!std::getline(ifs, map_line)) + break; + + iss = std::istringstream(map_line); + iss >> std::hex >> start; + iss >> dash; + iss >> std::hex >> end; + iss >> permission; + + if (permission != "r-xp") + break; + + char* from = reinterpret_cast(hugepage_align_up(start)); + char* to = reinterpret_cast(hugepage_align_down(end)); + + if (from >= to) + break; + + size_t size = to - from; + nregion.found_text_region = true; + nregion.from = from; + nregion.to = to; + nregion.total_hugepages = size / hps; + + break; } ifs.close(); @@ -408,14 +417,7 @@ int MapStaticCodeToLargePages() { return -1; } -#if defined(__linux__) || defined(__FreeBSD__) - if (r.from > reinterpret_cast(&MoveTextRegionToLargePages)) - return MoveTextRegionToLargePages(r); - - return -1; -#elif defined(__APPLE__) return MoveTextRegionToLargePages(r); -#endif } bool IsLargePagesEnabled() {