Skip to content

Commit 4e907e9

Browse files
committed
[ELF] -M/-Map: fix VMA/LMA/Size columns of symbol assignments when address/size>=2**32
SymbolAssignment::addr stores the ___location counter. The type should be uint64_t instead of unsigned. The upper half of the address space is commonly used by operating system kernels. Similarly, SymbolAssignment::size should be an uint64_t. A kernel linker script can move the ___location counter from 0 to the upper half of the address space. Reviewed By: grimar Differential Revision: https://reviews.llvm.org/D77445
1 parent 95eb50c commit 4e907e9

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

lld/ELF/LinkerScript.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,11 @@ struct SymbolAssignment : BaseCommand {
109109
std::string commandString;
110110

111111
// Address of this assignment command.
112-
unsigned addr;
112+
uint64_t addr;
113113

114114
// Size of this assignment command. This is usually 0, but if
115115
// you move '.' this may be greater than 0.
116-
unsigned size;
116+
uint64_t size;
117117
};
118118

119119
// Linker scripts allow additional constraints to be put on output sections.

lld/test/ELF/map-file-64bit.s

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# REQUIRES: x86
2+
## Test how we display the upper half of the address space, which is commonly
3+
## used by operating system kernels.
4+
5+
# RUN: llvm-mc -filetype=obj -triple=x86_64 /dev/null -o %t.o
6+
# RUN: ld.lld -M -T %s %t.o -o /dev/null | FileCheck %s --match-full-lines --strict-whitespace
7+
8+
## . = 0xffffffff80000000; has a misaligned Size column.
9+
# CHECK: VMA LMA Size Align Out In Symbol
10+
# CHECK-NEXT: 0 0 ffffffff80000000 1 . = 0xffffffff80000000
11+
# CHECK-NEXT:ffffffff80000000 0 100000 1 . += 0x100000
12+
# CHECK-NEXT:ffffffff80100000 0 0 1 _text = .
13+
# CHECK-NEXT:ffffffff80100000 ffffffff80100000 0 4 .text
14+
15+
SECTIONS {
16+
. = 0xffffffff80000000;
17+
. += 0x100000;
18+
_text = .;
19+
}

0 commit comments

Comments
 (0)