Skip to content

Commit

Permalink
move text_hash in delocate.go
Browse files Browse the repository at this point in the history
  • Loading branch information
dkostic committed Dec 9, 2024
1 parent 65808f8 commit c00d023
Show file tree
Hide file tree
Showing 18 changed files with 533 additions and 532 deletions.
15 changes: 8 additions & 7 deletions util/fipstools/delocate/delocate.go
Original file line number Diff line number Diff line change
Expand Up @@ -1959,6 +1959,14 @@ func transform(w stringWriter, includes []string, inputs []inputFile, startEndDe
w.WriteString(fmt.Sprintf(".file %d \"inserted_by_delocate.c\"%s\n", maxObservedFileNumber+1, fileTrailing))
w.WriteString(fmt.Sprintf(".loc %d 1 0\n", maxObservedFileNumber+1))
}

w.WriteString(".type BORINGSSL_bcm_text_hash, @object\n")
w.WriteString(".size BORINGSSL_bcm_text_hash, 32\n")
w.WriteString("BORINGSSL_bcm_text_hash:\n")
for _, b := range fipscommon.UninitHashValue {
w.WriteString(".byte 0x" + strconv.FormatUint(uint64(b), 16) + "\n")
}

if d.processor == aarch64 {
// Grab the address of BORINGSSL_bcm_test_[start,end] via a relocation
// from a redirector function. For this to work, need to add the markers
Expand Down Expand Up @@ -2139,13 +2147,6 @@ func transform(w stringWriter, includes []string, inputs []inputFile, startEndDe
}
}

w.WriteString(".type BORINGSSL_bcm_text_hash, @object\n")
w.WriteString(".size BORINGSSL_bcm_text_hash, 32\n")
w.WriteString("BORINGSSL_bcm_text_hash:\n")
for _, b := range fipscommon.UninitHashValue {
w.WriteString(".byte 0x" + strconv.FormatUint(uint64(b), 16) + "\n")
}

return nil
}

Expand Down
70 changes: 35 additions & 35 deletions util/fipstools/delocate/testdata/aarch64-Basic/out.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,41 @@
.text
.file 1 "inserted_by_delocate.c"
.loc 1 1 0
.type BORINGSSL_bcm_text_hash, @object
.size BORINGSSL_bcm_text_hash, 32
BORINGSSL_bcm_text_hash:
.byte 0xae
.byte 0x2c
.byte 0xea
.byte 0x2a
.byte 0xbd
.byte 0xa6
.byte 0xf3
.byte 0xec
.byte 0x97
.byte 0x7f
.byte 0x9b
.byte 0xf6
.byte 0x94
.byte 0x9a
.byte 0xfc
.byte 0x83
.byte 0x68
.byte 0x27
.byte 0xcb
.byte 0xa0
.byte 0xa0
.byte 0x9f
.byte 0x6b
.byte 0x6f
.byte 0xde
.byte 0x52
.byte 0xcd
.byte 0xe2
.byte 0xcd
.byte 0xff
.byte 0x31
.byte 0x80
.global BORINGSSL_bcm_text_start
.type BORINGSSL_bcm_text_start, @function
BORINGSSL_bcm_text_start:
Expand Down Expand Up @@ -261,38 +296,3 @@ bss_symbol_bss_get:
ret
.cfi_endproc
.size .LOPENSSL_armcap_P_addr, .-.LOPENSSL_armcap_P_addr
.type BORINGSSL_bcm_text_hash, @object
.size BORINGSSL_bcm_text_hash, 32
BORINGSSL_bcm_text_hash:
.byte 0xae
.byte 0x2c
.byte 0xea
.byte 0x2a
.byte 0xbd
.byte 0xa6
.byte 0xf3
.byte 0xec
.byte 0x97
.byte 0x7f
.byte 0x9b
.byte 0xf6
.byte 0x94
.byte 0x9a
.byte 0xfc
.byte 0x83
.byte 0x68
.byte 0x27
.byte 0xcb
.byte 0xa0
.byte 0xa0
.byte 0x9f
.byte 0x6b
.byte 0x6f
.byte 0xde
.byte 0x52
.byte 0xcd
.byte 0xe2
.byte 0xcd
.byte 0xff
.byte 0x31
.byte 0x80
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
.text
BORINGSSL_bcm_text_start:
.file 10 "some/path/file.c" "file.c"
.file 1000 "some/path/file2.c" "file2.c"
.file 1001 "some/path/file_with_md5.c" "other_name.c" md5 0x5eba7844df6449a7f2fff1556fe7ba8d239f8e2f

# An instruction is needed to satisfy the architecture auto-detection.
movq %rax, %rbx
.text
BORINGSSL_bcm_text_end:
.type OPENSSL_ia32cap_get, @function
.globl OPENSSL_ia32cap_get
.LOPENSSL_ia32cap_get_local_target:
OPENSSL_ia32cap_get:
leaq OPENSSL_ia32cap_P(%rip), %rax
ret
.type BORINGSSL_bcm_text_hash, @object
.size BORINGSSL_bcm_text_hash, 32
BORINGSSL_bcm_text_hash:
Expand Down Expand Up @@ -49,3 +34,18 @@ BORINGSSL_bcm_text_hash:
.byte 0xff
.byte 0x31
.byte 0x80
BORINGSSL_bcm_text_start:
.file 10 "some/path/file.c" "file.c"
.file 1000 "some/path/file2.c" "file2.c"
.file 1001 "some/path/file_with_md5.c" "other_name.c" md5 0x5eba7844df6449a7f2fff1556fe7ba8d239f8e2f

# An instruction is needed to satisfy the architecture auto-detection.
movq %rax, %rbx
.text
BORINGSSL_bcm_text_end:
.type OPENSSL_ia32cap_get, @function
.globl OPENSSL_ia32cap_get
.LOPENSSL_ia32cap_get_local_target:
OPENSSL_ia32cap_get:
leaq OPENSSL_ia32cap_P(%rip), %rax
ret
32 changes: 16 additions & 16 deletions util/fipstools/delocate/testdata/generic-FileDirectives/out.s
Original file line number Diff line number Diff line change
@@ -1,22 +1,6 @@
.text
.file 1002 "inserted_by_delocate.c" md5 0x00000000000000000000000000000000
.loc 1002 1 0
BORINGSSL_bcm_text_start:
.file 10 "some/path/file.c" "file.c"
.file 1000 "some/path/file2.c" "file2.c"
.file 1001 "some/path/file_with_md5.c" "other_name.c" md5 0x5eba7844df6449a7f2fff1556fe7ba8d239f8e2f

# An instruction is needed to satisfy the architecture auto-detection.
movq %rax, %rbx
.text
.loc 1002 2 0
BORINGSSL_bcm_text_end:
.type OPENSSL_ia32cap_get, @function
.globl OPENSSL_ia32cap_get
.LOPENSSL_ia32cap_get_local_target:
OPENSSL_ia32cap_get:
leaq OPENSSL_ia32cap_P(%rip), %rax
ret
.type BORINGSSL_bcm_text_hash, @object
.size BORINGSSL_bcm_text_hash, 32
BORINGSSL_bcm_text_hash:
Expand Down Expand Up @@ -52,3 +36,19 @@ BORINGSSL_bcm_text_hash:
.byte 0xff
.byte 0x31
.byte 0x80
BORINGSSL_bcm_text_start:
.file 10 "some/path/file.c" "file.c"
.file 1000 "some/path/file2.c" "file2.c"
.file 1001 "some/path/file_with_md5.c" "other_name.c" md5 0x5eba7844df6449a7f2fff1556fe7ba8d239f8e2f

# An instruction is needed to satisfy the architecture auto-detection.
movq %rax, %rbx
.text
.loc 1002 2 0
BORINGSSL_bcm_text_end:
.type OPENSSL_ia32cap_get, @function
.globl OPENSSL_ia32cap_get
.LOPENSSL_ia32cap_get_local_target:
OPENSSL_ia32cap_get:
leaq OPENSSL_ia32cap_P(%rip), %rax
ret
32 changes: 16 additions & 16 deletions util/fipstools/delocate/testdata/generic-Includes/out.s
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,6 @@
.text
.file 1002 "inserted_by_delocate.c" md5 0x00000000000000000000000000000000
.loc 1002 1 0
BORINGSSL_bcm_text_start:
.file 10 "some/path/file.c" "file.c"
.file 1000 "some/path/file2.c" "file2.c"
.file 1001 "some/path/file_with_md5.c" "other_name.c" md5 0x5eba7844df6449a7f2fff1556fe7ba8d239f8e2f

# An instruction is needed to satisfy the architecture auto-detection.
movq %rax, %rbx
.text
.loc 1002 2 0
BORINGSSL_bcm_text_end:
.type OPENSSL_ia32cap_get, @function
.globl OPENSSL_ia32cap_get
.LOPENSSL_ia32cap_get_local_target:
OPENSSL_ia32cap_get:
leaq OPENSSL_ia32cap_P(%rip), %rax
ret
.type BORINGSSL_bcm_text_hash, @object
.size BORINGSSL_bcm_text_hash, 32
BORINGSSL_bcm_text_hash:
Expand Down Expand Up @@ -54,3 +38,19 @@ BORINGSSL_bcm_text_hash:
.byte 0xff
.byte 0x31
.byte 0x80
BORINGSSL_bcm_text_start:
.file 10 "some/path/file.c" "file.c"
.file 1000 "some/path/file2.c" "file2.c"
.file 1001 "some/path/file_with_md5.c" "other_name.c" md5 0x5eba7844df6449a7f2fff1556fe7ba8d239f8e2f

# An instruction is needed to satisfy the architecture auto-detection.
movq %rax, %rbx
.text
.loc 1002 2 0
BORINGSSL_bcm_text_end:
.type OPENSSL_ia32cap_get, @function
.globl OPENSSL_ia32cap_get
.LOPENSSL_ia32cap_get_local_target:
OPENSSL_ia32cap_get:
leaq OPENSSL_ia32cap_P(%rip), %rax
ret
48 changes: 24 additions & 24 deletions util/fipstools/delocate/testdata/ppc64le-GlobalEntry/out.s
Original file line number Diff line number Diff line change
@@ -1,30 +1,6 @@
.text
.file 1 "inserted_by_delocate.c"
.loc 1 1 0
BORINGSSL_bcm_text_start:
.text
.Lfoo_local_target:
foo:
.LCF0:

0:

999:
addis 2, 12, .LBORINGSSL_external_toc-999b@ha
addi 2, 2, .LBORINGSSL_external_toc-999b@l
ld 12, 0(2)
add 2, 2, 12
# WAS addi 2,2,.TOC.-.LCF0@l
.localentry foo,.-foo
.Lfoo_local_entry:
.LVL0:

bl
.text
.loc 1 2 0
BORINGSSL_bcm_text_end:
.LBORINGSSL_external_toc:
.quad .TOC.-.LBORINGSSL_external_toc
.type BORINGSSL_bcm_text_hash, @object
.size BORINGSSL_bcm_text_hash, 32
BORINGSSL_bcm_text_hash:
Expand Down Expand Up @@ -60,3 +36,27 @@ BORINGSSL_bcm_text_hash:
.byte 0xff
.byte 0x31
.byte 0x80
BORINGSSL_bcm_text_start:
.text
.Lfoo_local_target:
foo:
.LCF0:

0:

999:
addis 2, 12, .LBORINGSSL_external_toc-999b@ha
addi 2, 2, .LBORINGSSL_external_toc-999b@l
ld 12, 0(2)
add 2, 2, 12
# WAS addi 2,2,.TOC.-.LCF0@l
.localentry foo,.-foo
.Lfoo_local_entry:
.LVL0:

bl
.text
.loc 1 2 0
BORINGSSL_bcm_text_end:
.LBORINGSSL_external_toc:
.quad .TOC.-.LBORINGSSL_external_toc
68 changes: 34 additions & 34 deletions util/fipstools/delocate/testdata/ppc64le-LoadToR0/out.s
Original file line number Diff line number Diff line change
@@ -1,40 +1,6 @@
.text
.file 1 "inserted_by_delocate.c"
.loc 1 1 0
BORINGSSL_bcm_text_start:
.text
.Lfoo_local_target:
foo:
# WAS addis 22,2,bar@toc@ha
# WAS ld 0,bar@toc@l(22)
addi 1, 1, -288
mflr 0
std 0, -8(1)
std 3, -16(1)
bl .Lbcm_loadtoc_bar
std 3, -24(1)
ld 3, -8(1)
mtlr 3
ld 0, -24(1)
ld 3, -16(1)
addi 1, 1, 288
addi 1, 1, -288
std 3, -8(1)
mr 3, 0
ld 0, 0(3)
ld 3, -8(1)
addi 1, 1, 288
.text
.loc 1 2 0
BORINGSSL_bcm_text_end:
.type bcm_loadtoc_bar, @function
bcm_loadtoc_bar:
.Lbcm_loadtoc_bar:
addis 3, 2, bar@toc@ha
addi 3, 3, bar@toc@l
blr
.LBORINGSSL_external_toc:
.quad .TOC.-.LBORINGSSL_external_toc
.type BORINGSSL_bcm_text_hash, @object
.size BORINGSSL_bcm_text_hash, 32
BORINGSSL_bcm_text_hash:
Expand Down Expand Up @@ -70,3 +36,37 @@ BORINGSSL_bcm_text_hash:
.byte 0xff
.byte 0x31
.byte 0x80
BORINGSSL_bcm_text_start:
.text
.Lfoo_local_target:
foo:
# WAS addis 22,2,bar@toc@ha
# WAS ld 0,bar@toc@l(22)
addi 1, 1, -288
mflr 0
std 0, -8(1)
std 3, -16(1)
bl .Lbcm_loadtoc_bar
std 3, -24(1)
ld 3, -8(1)
mtlr 3
ld 0, -24(1)
ld 3, -16(1)
addi 1, 1, 288
addi 1, 1, -288
std 3, -8(1)
mr 3, 0
ld 0, 0(3)
ld 3, -8(1)
addi 1, 1, 288
.text
.loc 1 2 0
BORINGSSL_bcm_text_end:
.type bcm_loadtoc_bar, @function
bcm_loadtoc_bar:
.Lbcm_loadtoc_bar:
addis 3, 2, bar@toc@ha
addi 3, 3, bar@toc@l
blr
.LBORINGSSL_external_toc:
.quad .TOC.-.LBORINGSSL_external_toc
Loading

0 comments on commit c00d023

Please sign in to comment.