aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2019-02-26 00:02:35 -0800
committerH. Peter Anvin <hpa@zytor.com>2019-02-26 00:02:35 -0800
commitb2004511dddeefd7c0866a33ceaa5fa1a6ee0510 (patch)
treebe9d710d81f6c985541f79a44919d8830bb04eab /test
parent437e0ffa01505d173a8b9cfe2decf74f2e9795a5 (diff)
downloadnasm-b2004511dddeefd7c0866a33ceaa5fa1a6ee0510.tar.gz
nasm-b2004511dddeefd7c0866a33ceaa5fa1a6ee0510.tar.xz
nasm-b2004511dddeefd7c0866a33ceaa5fa1a6ee0510.zip
ELF: handle more than 32,633 sections
Dead code elimination in ELF uses separate ELF sections for every functions or data items that may be garbage collected. This can end up being more than 32,633 sections which, when the ELF internal and relocation sections are added in, can exceed the legacy ELF maximum of 65,279 sections. Newer versions of the ELF specification has added support for much larger number of sections by putting a place holder value (usually SHN_XINDEX == 0xffff, but 0 in some cases) into fields where the section index is a 16-bit value, and storing the full value in a diffent place: the program header uses entries in section header 0, the symbol table uses an auxiliary segment with the additional indicies; the section header did not need it as the sh_link field is already 32 (or 64) bits long. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'test')
-rw-r--r--test/fewsecs.asm2
-rw-r--r--test/manysecs.asm13
-rw-r--r--test/moresecs.asm3
-rw-r--r--test/mostsecs.asm3
4 files changed, 19 insertions, 2 deletions
diff --git a/test/fewsecs.asm b/test/fewsecs.asm
new file mode 100644
index 00000000..85731acf
--- /dev/null
+++ b/test/fewsecs.asm
@@ -0,0 +1,2 @@
+%assign NSECS 64
+%include "manysecs.asm"
diff --git a/test/manysecs.asm b/test/manysecs.asm
index c65c6091..49799453 100644
--- a/test/manysecs.asm
+++ b/test/manysecs.asm
@@ -1,6 +1,15 @@
+%ifndef NSECS
+ %assign NSECS 16384
+%endif
+
+%assign NSECS ((NSECS+3) & ~3)
+
%assign n 0
-%rep 10000
+%rep NSECS
+ %assign gcom (n & ~3) + 2
section .text %+ n progbits exec
+start_ %+ n:
nop
-%assign n n+1
+ jmp start_ %+ gcom
+ %assign n n+1
%endrep
diff --git a/test/moresecs.asm b/test/moresecs.asm
new file mode 100644
index 00000000..78d9887b
--- /dev/null
+++ b/test/moresecs.asm
@@ -0,0 +1,3 @@
+; Less than 65,279 data sections, but more total sections
+%assign NSECS 37600
+%include "manysecs.asm"
diff --git a/test/mostsecs.asm b/test/mostsecs.asm
new file mode 100644
index 00000000..0b91816a
--- /dev/null
+++ b/test/mostsecs.asm
@@ -0,0 +1,3 @@
+; More than 65,279 data sections
+%assign NSECS 131072
+%include "manysecs.asm"