Ubuntu Linux 19.10, Kernel 5.3.0 prog.c ====== int start() { return 1; } ====== gcc -c -mcmodel=kernel -fno-PIC -O2 prog.c ld --oformat binary --entry start -Ttext 0xFFFFFFFFFF840000 -o prog.bin prog.o warning: writing section `.text' at huge (ie negative) file offset error: File truncated This error in ld 2.32 too. But this error occur in Ubuntu Linux 19.10. There is no error in Ubuntu Linux 19.04.
Please attach your compiled object file, so that we don't need to guess your compiler version and many other details. I could not reproduce this bug.
Created attachment 12058 [details] Object file maked in Ubuntu Linux 19.04
Created attachment 12059 [details] Object file maked in Ubuntu Linux 19.10
(In reply to Alan Modra from comment #1) > Please attach your compiled object file, so that we don't need to guess your > compiler version and many other details. I could not reproduce this bug. I am use default packages of gcc and binutils installed by default. Realy, nor ld version, nor gcc version do not matter. I already probing different versions. Have matter only building platform Ubuntu Linux 19.10 desktop x86_64, that is a problem. Previous version Ubuntu Linux 19.04 do not have this problem.
There is a .note.gnu.property section in your gcc-9 compiled object file. This section is an allocated section (and thus will appear in the binary output), and is placed by the generic linker before your .text section at a relatively low address. Combined with the very high address of your .text section would mean a binary format output file of around 18 exa bytes. I'm guessing that you don't have such a large storage system. Use -Ttext-segment=0xff... rather than -Ttext=0xff... when linking if you want the .note.gnu.property section in your output, compile with an option that turns it off, or remove the section before linking.
The -Ttext-segment resolve a problem. Do you know, how to compile with an option, that turns .note.gnu.property section off? I know, how to use strip, but it clears object so deep, and currently I simple shift 'start' entrypoint around .note.gnu.property section.
(In reply to Alexander Kobets from comment #6) > Do you know, how to compile with an option, that turns .note.gnu.property > section off? Not without spending some time looking. It is likely to be a -m option.
(In reply to Alexander Kobets from comment #6) > The -Ttext-segment resolve a problem. > Do you know, how to compile with an option, that turns .note.gnu.property > section off? > I know, how to use strip, but it clears object so deep, and currently I > simple shift 'start' entrypoint around .note.gnu.property section. .note.gnu.property note sections should be discarded in kernel image via linker script.
Ok.