Page MenuHomePhabricator

AMDGPU: Add 64-bit relative variant kind
ClosedPublic

Authored by kzhuravl on May 31 2018, 12:31 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

kzhuravl created this revision.May 31 2018, 12:31 PM

What is this actually needed for? Having a relative relocation in a data segment doesn't seem that useful?

What is this actually needed for? Having a relative relocation in a data segment doesn't seem that useful?

Never mind, I see it in the other commit. Could you please update the table of relocation types in AMDGPUUsage.rst? It has an R_AMDGPU_RELATIVE64, I don't know what that's about, but it doesn't mention R_AMDGPU_REL64.

t-tye added a comment.Jun 4 2018, 9:59 AM

What is this actually needed for? Having a relative relocation in a data segment doesn't seem that useful?

Never mind, I see it in the other commit. Could you please update the table of relocation types in AMDGPUUsage.rst? It has an R_AMDGPU_RELATIVE64, I don't know what that's about, but it doesn't mention R_AMDGPU_REL64.

The AMDGPU_REL64 is defined in AMDGPUUsage as:

'''
Relocation Type Kind Value Field Calculation
R_AMDGPU_REL64 Static 5 word64 S + A - P
'''

It is a static relocation used to create PC relative values between sections. For example, there is a field in the kernel descriptor that has to be the delta from the kernel descriptor to the kernel entry point. So if the kernel descriptor is put in a different section to the code, a static relocation record is need. It will be resolved when the executable is linked.

The R_AMDGPU_RELATIVE64 is a dynamic relocation record implemented by most targets to support having absolute addresses in data sections that need to be initialized to the address of a symbol in the same shared object. For example, a variable initialized to the address of another variable which is considered a compile time constant in languages such as C/C++.

What is this actually needed for? Having a relative relocation in a data segment doesn't seem that useful?

Never mind, I see it in the other commit. Could you please update the table of relocation types in AMDGPUUsage.rst? It has an R_AMDGPU_RELATIVE64, I don't know what that's about, but it doesn't mention R_AMDGPU_REL64.

The AMDGPU_REL64 is defined in AMDGPUUsage as:

'''
Relocation Type Kind Value Field Calculation
R_AMDGPU_REL64 Static 5 word64 S + A - P
'''

It is a static relocation used to create PC relative values between sections. For example, there is a field in the kernel descriptor that has to be the delta from the kernel descriptor to the kernel entry point. So if the kernel descriptor is put in a different section to the code, a static relocation record is need. It will be resolved when the executable is linked.

The R_AMDGPU_RELATIVE64 is a dynamic relocation record implemented by most targets to support having absolute addresses in data sections that need to be initialized to the address of a symbol in the same shared object. For example, a variable initialized to the address of another variable which is considered a compile time constant in languages such as C/C++.

Is current wording about R_AMDGPU_REL64 and R_AMDGPU_RELATIVE64 in AMDGPUUsage enough?

Sorry, I somehow managed to miss the REL64 definition. It's fine.

t-tye accepted this revision.Jun 7 2018, 2:53 PM

LGTM

This revision is now accepted and ready to land.Jun 7 2018, 2:53 PM
This revision was automatically updated to reflect the committed changes.