[PATCH] D111871: [ELF] Let sections reach the end of the address space

Peter Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 15 04:48:45 PDT 2021


peter.smith added a comment.

I was a bit confused initially by the title and description, had to read the code to work out what the change was for. IIUC the address range of the section is the half open interval [os->addr, os->addr + size) so LLD has an off by one error when checking that the section fits at the end of the address space calculation? Please forgive me if I've got the notation the wrong way around. My memory says [ ] = closed interval, including endpoints, () = open interval, not including endpoints, [ ) half open-interval including start but not end value.

Can you update the description to something similar to what you'd put in the commit message? "This is permitted by the GNU linker." is going to look a bit a bit sparse in the log.



================
Comment at: lld/ELF/Writer.cpp:2786
+  for (OutputSection *os : outputSections) {
+    if (os->size == 0)
+      continue;
----------------
I'f I've got this right then on a 32-bit target we can write a 0 sized OutputSection with a base address higher than UINT32_MAX and pass the check.

Perhaps something like:
uint64_t last_byte = (os->size) ? os->addr + (os->size - 1) :  os->addr;


================
Comment at: lld/test/ELF/linkerscript/i386-sections-until-end-of-va.s:8
+
+## .bar section has data in [0xfffffff0, 0xfffffff0 + 0x10] ==
+## [0xfffffff0, 0]. There is no overflow.
----------------
Expressed in bytes written I think it is [0xfffffff0, 0xfffffff0 + 0x10) to show that 0x100000000 (using 64-bit numbers) is not part of the interval.


================
Comment at: lld/test/ELF/linkerscript/i386-sections-until-end-of-va.s:9
+## .bar section has data in [0xfffffff0, 0xfffffff0 + 0x10] ==
+## [0xfffffff0, 0]. There is no overflow.
+
----------------
Expressed in bytes written I think this is [0xfffffff0, 0) == [0xfffffff0, 0xffffffff]


================
Comment at: lld/test/ELF/linkerscript/sections-until-end-of-va.s:8
+
+## .bar section has data in [0xfffffffffffffff0, 0xfffffffffffffff0 + 0x10] ==
+## [0xfffffffffffffff0, 0]. There is no overflow.
----------------
Similar comment to the above test case.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111871/new/

https://reviews.llvm.org/D111871



More information about the llvm-commits mailing list