Bug 26559 - Get OUTPUT_FORMAT from objdump -f to support LLD
Summary: Get OUTPUT_FORMAT from objdump -f to support LLD
Alias: None
Product: glibc
Classification: Unclassified
Component: build (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Blocks: 26558
  Show dependency treegraph
Reported: 2020-08-31 23:31 UTC by Fangrui Song
Modified: 2021-09-06 04:40 UTC (History)
1 user (show)

See Also:
Last reconfirmed:


Note You need to log in before you can comment on or make changes to this bug.
Description Fangrui Song 2020-08-31 23:31:14 UTC
OUTPUT_FORMAT is needed as the first line of libc.so (a linker script). The string comes from either

(a) ld --verbose on /dev/null, get the output (the OUTPUT_FORMAT line and the continuation lines), feed the output to scripts/output-format.sed
(b) ld --print-output-format

Neither choice makes sense for LLD. It supports multi targets and there is not a preferred default target. Like gold, it does not have the concept of "an internal linker script". ld.lld --verbose does not print OUTPUT_FORMAT.

As an alternative, we can get the string from objdump -f

% objdump -f /lib/x86_64-linux-gnu/libc.so.6 

/lib/x86_64-linux-gnu/libc.so.6:     file format elf64-x86-64

# LLVM>=11.0.0 (since https://reviews.llvm.org/D76046 )
% llvm-objdump -f /lib/x86_64-linux-gnu/libc.so.6

/lib/x86_64-linux-gnu/libc.so.6:        file format elf64-x86-64

architecture: x86_64
start address: 0x0000000000026e00
Comment 1 Fangrui Song 2021-09-06 04:40:38 UTC
Fixed by https://sourceware.org/git/?p=glibc.git;a=commit;h=02d393f2483aedc4ce74e6edf8a15f063198041d ("install: Replace scripts/output-format.sed with objdump -f [BZ #26559]") a while ago.