Commit 7abc8c4a authored by Ian Lance Taylor's avatar Ian Lance Taylor

debug/elf: add comments explaining applyRelocations for amd64/arm64

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/155190043
parent f1c0899e
...@@ -564,6 +564,10 @@ func (f *File) applyRelocationsAMD64(dst []byte, rels []byte) error { ...@@ -564,6 +564,10 @@ func (f *File) applyRelocationsAMD64(dst []byte, rels []byte) error {
continue continue
} }
// There are relocations, so this must be a normal
// object file, and we only look at section symbols,
// so we assume that the symbol value is 0.
switch t { switch t {
case R_X86_64_64: case R_X86_64_64:
if rela.Off+8 >= uint64(len(dst)) || rela.Addend < 0 { if rela.Off+8 >= uint64(len(dst)) || rela.Addend < 0 {
...@@ -646,6 +650,10 @@ func (f *File) applyRelocationsARM64(dst []byte, rels []byte) error { ...@@ -646,6 +650,10 @@ func (f *File) applyRelocationsARM64(dst []byte, rels []byte) error {
continue continue
} }
// There are relocations, so this must be a normal
// object file, and we only look at section symbols,
// so we assume that the symbol value is 0.
switch t { switch t {
case R_AARCH64_ABS64: case R_AARCH64_ABS64:
if rela.Off+8 >= uint64(len(dst)) || rela.Addend < 0 { if rela.Off+8 >= uint64(len(dst)) || rela.Addend < 0 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment