GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — src: start the .text section with an asm symbol · nodejs/node@70f0460

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • node.gyp
  • src/large_pages
    • node_large_page.cc
    • node_text_start.S
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎node.gyp‎

Copy file name to clipboardExpand all lines: node.gyp
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,19 @@
313313
},
314314

315315
'targets': [
316+
{
317+
'target_name': 'node_text_start',
318+
'type': 'none',
319+
'conditions': [
320+
[ 'OS=="linux" and '
321+
'target_arch=="x64"', {
322+
'type': 'static_library',
323+
'sources': [
324+
'src/large_pages/node_text_start.S'
325+
]
326+
}],
327+
]
328+
},
316329
{
317330
'target_name': '<(node_core_target_name)',
318331
'type': 'executable',
@@ -498,6 +511,13 @@
498511
'src/node_snapshot_stub.cc'
499512
],
500513
}],
514+
[ 'OS=="linux" and '
515+
'target_arch=="x64"', {
516+
'dependencies': [ 'node_text_start' ],
517+
'ldflags+': [
518+
'<(PRODUCT_DIR)/obj.target/node_text_start/src/large_pages/node_text_start.o'
519+
]
520+
}],
501521
],
502522
}, # node_core_target_name
503523
{
Collapse file

‎src/large_pages/node_large_page.cc‎

Copy file name to clipboardExpand all lines: src/large_pages/node_large_page.cc
+14-14Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,11 @@
7171

7272
#if defined(__linux__)
7373
extern "C" {
74-
extern char __executable_start;
74+
// This symbol must be declared weak because this file becomes part of all
75+
// Node.js targets (like node_mksnapshot, node_mkcodecache, and cctest) and
76+
// those files do not supply the symbol.
77+
extern char __attribute__((weak)) __node_text_start;
78+
extern char __start_lpstub;
7579
} // extern "C"
7680
#endif // defined(__linux__)
7781

@@ -121,6 +125,8 @@ struct text_region FindNodeTextRegion() {
121125
std::string dev;
122126
char dash;
123127
uintptr_t start, end, offset, inode;
128+
uintptr_t node_text_start = reinterpret_cast<uintptr_t>(&__node_text_start);
129+
uintptr_t lpstub_start = reinterpret_cast<uintptr_t>(&__start_lpstub);
124130

125131
ifs.open("/proc/self/maps");
126132
if (!ifs) {
@@ -144,21 +150,15 @@ struct text_region FindNodeTextRegion() {
144150
std::string pathname;
145151
iss >> pathname;
146152

147-
if (start != reinterpret_cast<uintptr_t>(&__executable_start))
153+
if (permission != "r-xp")
148154
continue;
149155

150-
// The next line is our .text section.
151-
if (!std::getline(ifs, map_line))
152-
break;
153-
154-
iss = std::istringstream(map_line);
155-
iss >> std::hex >> start;
156-
iss >> dash;
157-
iss >> std::hex >> end;
158-
iss >> permission;
156+
if (node_text_start < start || node_text_start >= end)
157+
continue;
159158

160-
if (permission != "r-xp")
161-
break;
159+
start = node_text_start;
160+
if (lpstub_start > start && lpstub_start <= end)
161+
end = lpstub_start;
162162

163163
char* from = reinterpret_cast<char*>(hugepage_align_up(start));
164164
char* to = reinterpret_cast<char*>(hugepage_align_down(end));
@@ -318,7 +318,7 @@ static bool IsSuperPagesEnabled() {
318318
// d. If successful copy the code there and unmap the original region
319319
int
320320
#if !defined(__APPLE__)
321-
__attribute__((__section__(".lpstub")))
321+
__attribute__((__section__("lpstub")))
322322
#else
323323
__attribute__((__section__("__TEXT,__lpstub")))
324324
#endif
Collapse file

‎src/large_pages/node_text_start.S‎

Copy file name to clipboard
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.text
2+
.align 0x2000
3+
.global __node_text_start
4+
.hidden __node_text_start
5+
__node_text_start:

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.