1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 20:23:11 +01:00
llvm-mirror/test/MC/ELF/section-combine.s
Fangrui Song fdfda04ad5 [MC][ELF] Make linked-to symbol name part of ELFSectionKey
https://bugs.llvm.org/show_bug.cgi?id=44775

This rule has been implemented by GNU as https://sourceware.org/ml/binutils/2020-02/msg00028.html (binutils >= 2.35)

It allows us to simplify

```
.section .foo,"o",foo,unique,0
.section .foo,"o",bar,unique,1  # different section
```

to

```
.section .foo,"o",foo
.section .foo,"o",bar  # different section
```

We consider the two `.foo` different even if the linked-to symbols foo and bar
are defined in the same section.  This is a deliberate choice so that we don't
need to know the section where foo and bar are defined beforehand.

Differential Revision: https://reviews.llvm.org/D74006
2020-02-14 20:03:04 -08:00

49 lines
1.3 KiB
ArmAsm

## Sections are differentiated by the quadruple
## (section_name, group_name, unique_id, link_to_symbol_name).
## Sections sharing the same quadruple are combined into one section.
# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t
# RUN: llvm-readelf -x .foo %t | FileCheck %s
# CHECK: Hex dump of section '.foo':
# CHECK-NEXT: 0x00000000 00
# CHECK: Hex dump of section '.foo':
# CHECK-NEXT: 0x00000000 0102
# CHECK: Hex dump of section '.foo':
# CHECK-NEXT: 0x00000000 03
# CHECK: Hex dump of section '.foo':
# CHECK-NEXT: 0x00000000 0405
# CHECK: Hex dump of section '.foo':
# CHECK-NEXT: 0x00000000 06
# CHECK: Hex dump of section '.foo':
# CHECK-NEXT: 0x00000000 0708
foo:
bar:
## foo and bar are in the same section. However, a section referencing foo
## is considered different from a section referencing bar.
.section .foo,"o",@progbits,foo
.byte 0
.section .foo,"o",@progbits,bar
.byte 1
.section .foo,"o",@progbits,bar
.byte 2
.section .foo,"o",@progbits,bar,unique,0
.byte 3
.section .foo,"o",@progbits,bar,unique,1
.byte 4
.section .foo,"o",@progbits,bar,unique,1
.byte 5
.section .foo,"Go",@progbits,comdat0,comdat,bar,unique,1
.byte 6
.section .foo,"Go",@progbits,comdat1,comdat,bar,unique,1
.byte 7
.section .foo,"Go",@progbits,comdat1,comdat,bar,unique,1
.byte 8