Skip to content

Commit

Permalink
Deifne relocation for ULEB128 value
Browse files Browse the repository at this point in the history
ULEB128 has used in DWARF and exception handling table, it used to
record value, or record the distance between two symbols.

The later one would be an issue for debug info and exception handling
table, since the symbol address might updated during, then the value
might incorrect after relaxation, some of those field has alternative
encoding type, but some new field defined in DWARF 5 ins't provide
alternative format other than ULEB128, e.g. DW_RLE_offset_pair,
DW_RLE_startx_length, DW_RLE_startx_endx and DW_RLE_start_length.

This PR basically same as #162, but updated to the trunk,
and also document ULEB128 should not shrink the size of the data,
since we never know the data used in where and does the length has
recorded in somewhere or not, so this would be most safe way.

binutils patch: https://sourceware.org/pipermail/binutils/2020-January/109672.html
  • Loading branch information
kito-cheng committed Jan 30, 2023
1 parent 9a77e88 commit e6a905c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions riscv-elf.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,10 @@ Description:: Additional information about the relocation
<| S + A - P
.2+| 58 .2+| IRELATIVE .2+| Dynamic | _wordclass_ .2+| Relocation against a non-preemptible ifunc symbol
<| `ifunc_resolver(B + A)`
.2+| 59 .2+| SET_ULEB128 .2+| Static | _ULEB128_ .2+| Local label assignment
<| S + A
.2+| 60 .2+| SUB_ULEB128 .2+| Static | _ULEB128_ .2+| Local label subtraction
<| V - S + A
.2+| 59-191 .2+| *Reserved* .2+| - | .2+| Reserved for future standard use
<|
.2+| 192-255 .2+| *Reserved* .2+| - | .2+| Reserved for nonstandard ABI extensions
Expand Down Expand Up @@ -499,6 +503,7 @@ of the `__global_pointer$` symbol into register `gp` (aka `x3`).
| _word16_ | Specifies a 16-bit word
| _word32_ | Specifies a 32-bit word
| _word64_ | Specifies a 64-bit word
| _ULEB128_ | Specifies a variable-length data encoded in ULEB128 format.
| _wordclass_ | Specifies a _word32_ field for ILP32 or a _word64_ field for LP64
| _B-Type_ | Specifies a field as the immediate field in a B-type instruction
| _CB-Type_ | Specifies a field as the immediate field in a CB-type instruction
Expand Down Expand Up @@ -1157,6 +1162,12 @@ are commonly resolved at compile-time, such as intra-function jumps), code
generators must in general ensure that relocations are always emitted when
relaxation is enabled.

Linker should adjust relocations which refer to those symbol has updated the
address.

ULEB128 value with relocation must be padding to the same length even if the
data can be encoded with a shorter byte sequence after linker relaxation.

=== Linker Relaxation Types

The purpose of this section is to describe all types of linker relaxation,
Expand Down

0 comments on commit e6a905c

Please sign in to comment.