mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-09 04:21:49 +08:00
fdb2b35b8f
There are two linker scripts, code-model-01.ld and code-model-02.ld, which are corresponding to the two different memory layouts, * code-model-01.ld: the text section is in the 32-bit address range, but the data section is far away from the text section, which means the data section is over the 32-bit address range. * code-model-02.ld: the text section is over the 32-bit address range, but the data section is placed nearly zero address. We use the two linker scripts, to test the current medlow and medany behaviors of GNU ld, including the weak symbol references and the relaxations behaviors. Besides, these testcases also show the limits of the current medlow and medany code models, that is - we may get the truncated to fit errors when linking with the above two linker scripts. ld/ * testsuite/ld-riscv-elf/code-model-01.ld: New testcases to test the behaviors of the current medlow and medany code models. * testsuite/ld-riscv-elf/code-model-02.ld: Likewise. * testsuite/ld-riscv-elf/code-model-medany-01.d: Likewise. * testsuite/ld-riscv-elf/code-model-medany-02.d: Likewise. * testsuite/ld-riscv-elf/code-model-medany-weakref-01.d: Likewise. * testsuite/ld-riscv-elf/code-model-medany-weakref-02.d: Likewise. * testsuite/ld-riscv-elf/code-model-medlow-01.d: Likewise. * testsuite/ld-riscv-elf/code-model-medlow-02.d: Likewise. * testsuite/ld-riscv-elf/code-model-medlow-weakref-01.d: Likewise. * testsuite/ld-riscv-elf/code-model-medlow-weakref-02.d: Likewise. * testsuite/ld-riscv-elf/code-model-relax-medany-01.d: Likewise. * testsuite/ld-riscv-elf/code-model-relax-medany-02.d: Likewise. * testsuite/ld-riscv-elf/code-model-relax-medany-weakref-01.d: Likewise. * testsuite/ld-riscv-elf/code-model-relax-medany-weakref-02.d: Likewise. * testsuite/ld-riscv-elf/code-model-relax-medlow-01.d: Likewise. * testsuite/ld-riscv-elf/code-model-relax-medlow-02.d: Likewise. * testsuite/ld-riscv-elf/code-model-relax-medlow-weakref-01.d: Likewise. * testsuite/ld-riscv-elf/code-model-relax-medlow-weakref-02.d: Likewise. * testsuite/ld-riscv-elf/code-model.s: Likewise. * testsuite/ld-riscv-elf/ld-riscv-elf.exp: Updated.
48 lines
916 B
ArmAsm
48 lines
916 B
ArmAsm
.text
|
|
.global _start
|
|
_start:
|
|
|
|
.ifdef __medany__
|
|
.option pic
|
|
.ifdef __undefweak__
|
|
# Refer to undefined weak symbol by GOT_PCREL.
|
|
la t0, symbolW
|
|
.option nopic
|
|
.else
|
|
# Refer to global data symbol by GOT_PCREL.
|
|
la t0, symbolG
|
|
.option nopic
|
|
# Refer to local data symbol by PCREL.
|
|
lla t0, symbolL
|
|
# Refer to non-pic data global symbol by PCREL.
|
|
la t0, symbolG
|
|
.endif
|
|
.endif
|
|
|
|
.ifdef __medlow__
|
|
.ifdef __undefweak__
|
|
# Refer to undefined weak symbol by absolutely access.
|
|
lui t0, %hi(symbolW)
|
|
addi t0, t0, %lo(symbolW)
|
|
.else
|
|
# Refer to local data symbol by absolutely access.
|
|
lui t0, %hi(symbolL)
|
|
addi t0, t0, %lo(symbolL)
|
|
# Refer to global data symbol by absolutely access.
|
|
lui t0, %hi(symbolG)
|
|
addi t0, t0, %lo(symbolG)
|
|
.endif
|
|
.endif
|
|
.size _start, .-_start
|
|
|
|
.data
|
|
.global symbolG
|
|
symbolL:
|
|
.dword 0x1111222233334444
|
|
symbolG:
|
|
.dword 0x5555666677778888
|
|
|
|
.ifdef __undefweak__
|
|
.weak symbolW
|
|
.endif
|