Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ELF] Change build-id default to sha1 #93943

Merged
merged 1 commit into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lld/ELF/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def Bstatic: F<"Bstatic">, HelpText<"Do not link against shared libraries">;

def build_id: J<"build-id=">, HelpText<"Generate build ID note">,
MetaVarName<"[fast,md5,sha1,uuid,0x<hexstring>]">;
def : F<"build-id">, Alias<build_id>, AliasArgs<["fast"]>, HelpText<"Alias for --build-id=fast">;
def : F<"build-id">, Alias<build_id>, AliasArgs<["sha1"]>, HelpText<"Alias for --build-id=sha1">;

defm check_sections: B<"check-sections",
"Check section addresses for overlaps (default)",
Expand Down
3 changes: 3 additions & 0 deletions lld/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ ELF Improvements
and combine relocation sections if their relocated section group members are
placed to the same output section.
(`#94704 <https://github.com/llvm/llvm-project/pull/94704>`_)
* ``--build-id`` now defaults to generating a 20-byte digest ("sha1") instead
of 8-byte ("fast"). This improves compatibility with RPM packaging tools.
(`#93943 <https://github.com/llvm/llvm-project/pull/93943>`_)

Breaking changes
----------------
Expand Down
2 changes: 1 addition & 1 deletion lld/docs/ld.lld.1
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ are calculated from the object contents.
is not intended to be cryptographically secure.
.It Fl -build-id
Synonym for
.Fl -build-id Ns = Ns Cm fast .
.Fl -build-id Ns = Ns Cm sha1 .
.It Fl -call-graph-profile-sort Ns = Ns Ar algorithm
.Ar algorithm
may be:
Expand Down
19 changes: 10 additions & 9 deletions lld/test/ELF/build-id.s
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
# RUN: llvm-readobj -S %t2 | FileCheck -check-prefix=ALIGN %s

# RUN: ld.lld --build-id %t -o %t2
# RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=DEFAULT %s
# RUN: ld.lld --build-id=fast %t -o %t2
# RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=DEFAULT %s
# RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=SHA1 %s
# RUN: ld.lld --build-id %t -o %t2 --threads=1
# RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=DEFAULT %s
# RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=SHA1 %s

# RUN: ld.lld --build-id=fast %t -o %t2
# RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=FAST %s

# RUN: ld.lld --build-id=md5 %t -o %t2
# RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=MD5 %s
Expand Down Expand Up @@ -41,7 +42,7 @@
# RUN: ld.lld --build-id --build-id=none %t -o %t2
# RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=NONE %s
# RUN: ld.lld --build-id=none --build-id %t -o %t2
# RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=DEFAULT %s
# RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=SHA1 %s

.globl _start
_start:
Expand All @@ -62,10 +63,10 @@ _start:
# ALIGN-NEXT: Info:
# ALIGN-NEXT: AddressAlignment: 4

# DEFAULT: Contents of section .note.test:
# DEFAULT: Contents of section .note.gnu.build-id:
# DEFAULT-NEXT: 04000000 08000000 03000000 474e5500 ............GNU.
# DEFAULT-NEXT: 630bc2f5 a2584763
# FAST: Contents of section .note.test:
# FAST: Contents of section .note.gnu.build-id:
# FAST-NEXT: 04000000 08000000 03000000 474e5500 ............GNU.
# FAST-NEXT: 630bc2f5 a2584763

# MD5: Contents of section .note.gnu.build-id:
# MD5-NEXT: 04000000 10000000 03000000 474e5500 ............GNU.
Expand Down
Loading