forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[nanoMIPS][LLD] Change in linker script parsing
Changed parsing of the linker script, as some nanoMIPS linker scripts require different set of rules for parsing: - Dot operator can be used as section address expression, and its value should be determined by the latest value of dot, not the current position in the memory region - Alignment for output section is not ignored for nanoMIPS if output section has got address expression - SHT_NOBITS sections don't occupy load addresses - OVERLAY sections can have a load region and assignment or byte commands in them.
- Loading branch information
1 parent
2e453dc
commit e1619d4
Showing
10 changed files
with
311 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
MEMORY { | ||
SEG1 : ORIGIN = 0x1000, LENGTH = 0x1000 | ||
SEG2 : ORIGIN = 0x2000, LENGTH = 0x1000 | ||
} | ||
|
||
SECTIONS { | ||
|
||
.text : { | ||
*(.text) | ||
} > SEG1 AT> SEG1 | ||
|
||
.first ORIGIN(SEG2) + SIZEOF(.text) : ALIGN(0x20) { | ||
*(.first) | ||
} > SEG2 AT> SEG1 | ||
|
||
.second : ALIGN(0x40) { | ||
*(.second) | ||
} > SEG2 AT> SEG1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
MEMORY { | ||
SEG1 : ORIGIN = 0x1000, LENGTH = 0x1000 | ||
} | ||
|
||
SECTIONS { | ||
|
||
.text : { | ||
*(.text) | ||
} > SEG1 AT> SEG1 | ||
|
||
. = ALIGN(0x100); | ||
|
||
.first . : { | ||
*(.first) | ||
} > SEG1 AT> SEG1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
MEMORY { | ||
SEG1 : ORIGIN = 0x1000, LENGTH = 0x1000 | ||
SEG2 : ORIGIN = 0x2000, LENGTH = 0x1000 | ||
} | ||
|
||
SECTIONS { | ||
|
||
.text : { | ||
*(.text) | ||
} > SEG1 AT> SEG1 | ||
|
||
.first (NOLOAD) : { | ||
*(.first) | ||
} > SEG2 AT> SEG1 | ||
|
||
.second : { | ||
*(.second) | ||
} > SEG2 AT> SEG1 | ||
|
||
.third (NOLOAD) : { | ||
*(.third) | ||
} > SEG2 AT> SEG1 | ||
|
||
.nanoMIPS.abiflags : { | ||
*(.nanoMIPS.abiflags) | ||
} > SEG2 AT> SEG1 | ||
|
||
|
||
|
||
.bss : { | ||
*(.bss) | ||
} > SEG2 AT> SEG1 | ||
|
||
.data : { | ||
*(.data) | ||
} > SEG2 AT> SEG1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# REQUIRES: nanomips | ||
|
||
|
||
# RUN: llvm-mc -filetype=obj -triple nanomips-elf -mcpu=i7200 %s -o %t.o | ||
# RUN: ld.lld -T %S/Inputs/nanomips-align-outsec.ld %t.o -o %t | ||
# RUN: llvm-objdump -h --triple=nanomips-elf --mcpu=i7200 %t | FileCheck %s | ||
# RUN: llvm-objdump -p --triple=nanomips-elf --mcpu=i7200 %t | FileCheck %s --check-prefix=CHECK-PHDR | ||
|
||
# CHECK: .first 00000004 00002020 00001020 | ||
# CHECK-NEXT: .second 00000004 00002040 00001040 | ||
|
||
|
||
# CHECK-PHDR: 0x00002020 vaddr 0x00002020 paddr 0x00001020 | ||
# CHECK-PHDR: 0x00002040 vaddr 0x00002040 paddr 0x00001040 | ||
|
||
.section .text, "ax", @progbits | ||
.align 1 | ||
.globl _start | ||
.ent _start | ||
|
||
_start: | ||
addiu $a1, $a2, 1 | ||
|
||
.end _start | ||
.size _start, .-_start | ||
|
||
.section .first, "ax", @progbits | ||
.align 1 | ||
.globl first_fun | ||
.ent first_fun | ||
|
||
first_fun: | ||
addiu $a1, $a2, 2 | ||
|
||
.end first_fun | ||
.size first_fun, .-first_fun | ||
|
||
.section .second, "ax", @progbits | ||
.align 1 | ||
.globl second_fun | ||
.ent second_fun | ||
|
||
second_fun: | ||
beqic $a1, 2, second_fun | ||
|
||
.end second_fun | ||
.size second_fun, .-second_fun |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# REQUIRES: nanomips | ||
|
||
|
||
# RUN: llvm-mc -filetype=obj -triple nanomips-elf -mcpu=i7200 %s -o %t.o | ||
# RUN: ld.lld -T %S/Inputs/nanomips-dot-adjust.ld %t.o -o %t | ||
# RUN: llvm-objdump -h --triple=nanomips-elf --mcpu=i7200 %t | FileCheck %s | ||
|
||
# CHECK: .text {{[0-9a-fA-F]*}} 00001000 | ||
# CHECK-NEXT: .first {{[0-9a-fA-F]*}} 00001100 | ||
|
||
.section .text, "ax", @progbits | ||
.align 1 | ||
.globl _start | ||
.ent _start | ||
|
||
_start: | ||
addiu $a1, $a2, 1 | ||
|
||
.end _start | ||
.size _start, .-_start | ||
|
||
.section .first, "ax", @progbits | ||
.align 1 | ||
.globl first_fun | ||
.ent first_fun | ||
|
||
first_fun: | ||
addiu $a1, $a2, 2 | ||
|
||
.end first_fun | ||
.size first_fun, .-first_fun |
Oops, something went wrong.