Discussion:
[bug #46986] Fails to build on FreeBSD CURRENT amd64
Kostya Berger
2016-01-27 01:19:25 UTC
Permalink
URL:
<http://savannah.gnu.org/bugs/?46986>

Summary: Fails to build on FreeBSD CURRENT amd64
Project: GNU GRUB
Submitted by: bergerkos
Submitted on: Wed 27 Jan 2016 01:19:24 AM GMT
Category: Compilation
Severity: Major
Priority: 5 - Normal
Item Group: None
Status: None
Privacy: Public
Assigned to: None
Originator Name: bergerkos
Originator Email: ***@yahoo.co.uk
Open/Closed: Open
Discussion Lock: Any
Release:
Release: Git master
Reproducibility: Every Time
Planned Release: None

_______________________________________________________

Details:

Fails to build. Git bisect shows first failing commit to be
a7cf8b1e235fbbc8a460510615c7ff85f21c2d05
Used GCC version = 4.8.5_2

Failing command:
...
mv syminfo.lst.new syminfo.lst
cat syminfo.lst | sort | /usr/bin/awk -f ./genmoddep.awk > moddep.lst || (rm
-f moddep.lst; exit 1)
gcc -o build-grub-module-verifier -I../include
-DGRUB_FILE=\".util/grub-module-verifier.c\" -I. -I. -I.. -I.. -I../include
-I../include -I../grub-core/lib/libgcrypt-grub/src/ -DGRUB_BUILD=1
-DGRUB_UTIL=1 -DGRUB_BUILD_PROGRAM_NAME=\"build-grub-module-verifier\"
../util/grub-module-verifier.c ../util/grub-module-verifier32.c
../util/grub-module-verifier64.c ../grub-core/kern/emu/misc.c ../util/misc.c
TARGET_OBJ2ELF= sh genmod.sh moddep.lst disk.module build-grub-module-verifier
disk.mod
TARGET_OBJ2ELF= sh genmod.sh moddep.lst trig.module build-grub-module-verifier
trig.mod
....
TARGET_OBJ2ELF= sh genmod.sh moddep.lst all_video.module
build-grub-module-verifier all_video.mod
build-grub-module-verifier: error: no symbol table.
Makefile:42419: recipe for target 'all_video.mod' failed
gmake[5]: *** [all_video.mod] Error 1
gmake[5]: Leaving directory
'/home/kostya/grub2-dev/work/grub-a7cf8b1e235fbbc8a460510615c7ff85f21c2d05/grub-core'





_______________________________________________________

Reply to this item at:

<http://savannah.gnu.org/bugs/?46986>

_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
Andrei Borzenkov
2016-01-27 03:40:45 UTC
Permalink
Follow-up Comment #1, bug #46986 (project grub):

Please attach all_video.module and all_video.mod.tmp (latter should be left by
genmod.sh). Also full configure and make log.

_______________________________________________________

Reply to this item at:

<http://savannah.gnu.org/bugs/?46986>

_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
Kostya Berger
2016-01-27 17:27:54 UTC
Permalink
Follow-up Comment #2, bug #46986 (project grub):

For which build? For the last or for the first bad (i.e.
a7cf8b1e235fbbc8a460510615c7ff85f21c2d05) ?

_______________________________________________________

Reply to this item at:

<http://savannah.gnu.org/bugs/?46986>

_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
Andrei Borzenkov
2016-01-27 17:40:41 UTC
Permalink
Follow-up Comment #3, bug #46986 (project grub):

It does not really matter. Commit you mention introduced module verifier,
which is why it is the first to fail. The problem is most likely in your
toolchain, but we need to see what sections actually exist in object. I guess
make output is not needed, but configure and config.log would be useful.

_______________________________________________________

Reply to this item at:

<http://savannah.gnu.org/bugs/?46986>

_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
Kostya Berger
2016-01-27 18:38:22 UTC
Permalink
Follow-up Comment #4, bug #46986 (project grub):

Here you are.

(file #36182, file #36183, file #36184)
_______________________________________________________

Additional Item Attachment:

File name: all_video.module Size:5 KB
File name: config.log Size:676 KB
File name: all_video.mod.tmp Size:0 KB


_______________________________________________________

Reply to this item at:

<http://savannah.gnu.org/bugs/?46986>

_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
Kostya Berger
2016-01-27 18:40:25 UTC
Permalink
Follow-up Comment #5, bug #46986 (project grub):

Here, configure output, too.

(file #36185)
_______________________________________________________

Additional Item Attachment:

File name: configure.output.txt Size:31 KB


_______________________________________________________

Reply to this item at:

<http://savannah.gnu.org/bugs/?46986>

_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
Andrei Borzenkov
2016-01-27 19:07:49 UTC
Permalink
Follow-up Comment #6, bug #46986 (project grub):

This is something with your toolchain. When I generate module from the same
all_video.module sumbol table is preserved. Try to execute step by step
manually (see grub-core/genmod.sh) to find out when it gets lost.

***@bor-Latitude-E5450:~/build/grub/grub-core$ TARGET_OBJ2ELF= sh genmod.sh
moddep.lst all_video.module build-grub-module-verifier all_video.mod
***@bor-Latitude-E5450:~/build/grub/grub-core$ LC_ALL=C objdump -x
all_video.mod
all_video.mod: file format elf32-i386
all_video.mod
architecture: i386, flags 0x00000010:
HAS_SYMS
start address 0x00000000

Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000000 00000000 00000000 00000034 2**0
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .data 00000000 00000000 00000000 00000034 2**0
CONTENTS, ALLOC, LOAD, DATA
2 .module_license 0000000f 00000000 00000000 00000034 2**0
CONTENTS, ALLOC, LOAD, DATA
3 .bss 00000000 00000000 00000000 00000043 2**0
ALLOC
4 .moddeps 00000021 00000000 00000000 00000043 2**0
CONTENTS, READONLY
5 .modname 0000000a 00000000 00000000 00000064 2**0
CONTENTS, READONLY
SYMBOL TABLE:
00000000 l d .text 00000000 .text
00000000 l d .data 00000000 .data
00000000 l d .module_license 00000000 .module_license
00000000 l d .bss 00000000 .bss
00000000 l d .moddeps 00000000 .moddeps
00000000 l d .modname 00000000 .modname


***@bor-Latitude-E5450:~/build/grub/grub-core$ LC_ALL=C objdump -x
/tmp/all_video.mod.46986

/tmp/all_video.mod.46986: file format elf32-i386
/tmp/all_video.mod.46986
architecture: i386, flags 0x00000000:

start address 0x00000000

Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000000 00000000 00000000 00000034 2**0
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .data 00000000 00000000 00000000 00000034 2**0
CONTENTS, ALLOC, LOAD, DATA
2 .module_license 0000000f 00000000 00000000 00000034 2**0
CONTENTS, ALLOC, LOAD, DATA
3 .bss 00000000 00000000 00000000 00000043 2**0
ALLOC
4 .moddeps 00000021 00000000 00000000 00000043 2**0
CONTENTS, READONLY
5 .modname 0000000a 00000000 00000000 00000064 2**0
CONTENTS, READONLY
SYMBOL TABLE:
no symbols


***@bor-Latitude-E5450:~/build/grub/grub-core$


_______________________________________________________

Reply to this item at:

<http://savannah.gnu.org/bugs/?46986>

_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
Kostya Berger
2016-01-27 19:43:39 UTC
Permalink
Follow-up Comment #7, bug #46986 (project grub):

Here is the debug output of the command you suggested:

TARGET_OBJ2ELF= sh -x genmod.sh moddep.lst all_video.module
build-grub-module-verifier all_video.mod

+ set -e
+ moddep=moddep.lst
+ infile=all_video.module
+ outfile=all_video.mod
+ tmpfile=all_video.mod.tmp
+ echo all_video.module
+ sed -e '***@.module.*$@@'
+ modname=all_video
+ grep ^all_video: moddep.lst
exit 0
+ grep ^all_video: moddep.lst
+ sed 's@^.*:@@'
+ deps=' vbe vga video_bochs video_cirrus'
+ rm -f all_video.mod.tmp all_video.mod
+ test x0 '!=' x1
+ objcopy -R .modname -R .moddeps all_video.module all_video.mod.tmp
+ mktemp /tmp/tmp.XXXXXXXXXX
+ t1=/tmp/tmp.t9sjgVroO4
+ printf 'all_video '
+ mktemp /tmp/tmp.XXXXXXXXXX
+ t2=/tmp/tmp.gh7SdJ96c2
+ printf 'vbe '
+ printf 'vga '
+ printf 'video_bochs '
+ printf 'video_cirrus '
+ test -n ' vbe vga video_bochs video_cirrus'
+ objcopy --add-section '.modname=/tmp/tmp.t9sjgVroO4' --add-section
'.moddeps=/tmp/tmp.gh7SdJ96c2' all_video.mod.tmp
+ rm -f /tmp/tmp.t9sjgVroO4 /tmp/tmp.gh7SdJ96c2
+ test xpc '!=' xemu
+ strip --strip-unneeded -K grub_mod_init -K grub_mod_fini -K _grub_mod_init
-K _grub_mod_fini -R .note.gnu.gold-version -R .note.GNU-stack -R .note -R
.comment all_video.mod.tmp
+ test -z ''
+ ./build-grub-module-verifier all_video.mod.tmp i386
build-grub-module-verifier: error: no symbol table.

Now I commented out in genmod.sh the line to remove $t1 and $t2 in order to
see what gets there.
So the one contains "all_video", while the other contains
"vbevgavideo_bochsvideo_cirrus". Should it not be rather "vbe vga video_bosh
video_cirrus"?

_______________________________________________________

Reply to this item at:

<http://savannah.gnu.org/bugs/?46986>

_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
Andrei Borzenkov
2016-01-27 19:56:15 UTC
Permalink
Follow-up Comment #8, bug #46986 (project grub):

You misunderstand. It is clear what this script does. But either objcopy or
strip removes more than expected. So you need to check result of these
commands using "objdump -t" to see when symbol table gets lost.

I'm pretty sure it is strip, and actually those symbols are not needed for
linking indeed. What version are you using (strip -V and objcopy -V)?

_______________________________________________________

Reply to this item at:

<http://savannah.gnu.org/bugs/?46986>

_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
Kostya Berger
2016-01-27 20:08:49 UTC
Permalink
Follow-up Comment #9, bug #46986 (project grub):

Sorry, I'm not a programmer, that's why.

strip -V: strip (elftoolchain r3223M)
objcopy -V: GNU objcopy 2.17.50 [FreeBSD] 2007-07-03

Interestingly, in FreeBSD 10.2 man strip it says "GNU strip...". Here on
CURRENT it doesn't mention GNU...

Know what? I'll check how it builds on STABLE and report back.

_______________________________________________________

Reply to this item at:

<http://savannah.gnu.org/bugs/?46986>

_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
Kostya Berger
2016-01-27 20:26:12 UTC
Permalink
Follow-up Comment #10, bug #46986 (project grub):

Doesn't build either. And here strip is GNU strip 2.17.50

_______________________________________________________

Reply to this item at:

<http://savannah.gnu.org/bugs/?46986>

_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
Kostya Berger
2016-01-27 21:03:15 UTC
Permalink
Follow-up Comment #11, bug #46986 (project grub):

Don't know if it matters as I'm not a programmer... but genmod.sh has changed
in the version that fails compared to the previous one.

The strip command in the failing revision is:
strip --strip-unneeded -K grub_mod_init -K grub_mod_fini -K _grub_mod_init -K
_grub_mod_fini -R .note.gnu.gold-version -R .note.GNU-stack -R .note -R
.comment all_video.mod.tmp

And in the one that doesn't fail it is:
strip --strip-unneeded -K grub_mod_init -K grub_mod_fini -K _grub_mod_init -K
_grub_mod_fini -R .note.gnu.gold-version -R .note.GNU-stack -R .note -R
.comment build-grub-module-verifier.tmp

So, in the first case it is all_video.mod.tmp is being stripped, in the second
it is build-grub-module-verifier.tmp.

Also, in the successful build all_video.mod has no symbols either, but nobody
cares in this case.

_______________________________________________________

Reply to this item at:

<http://savannah.gnu.org/bugs/?46986>

_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
Vladimir Serbinenko
2016-01-27 21:07:24 UTC
Permalink
Follow-up Comment #12, bug #46986 (project grub):

Before module verifier this problem just resulted in unloadable module. You
can disable check in module verifier but it will not do any good as runtime
has the same check. And if you bypass check at runtime you're likely to bit a
null pointer dereference. If we want to support symbolless modules we need
more work to make them work. Alternative is to put a fake symbol

_______________________________________________________

Reply to this item at:

<http://savannah.gnu.org/bugs/?46986>

_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
Kostya Berger
2016-01-27 21:27:35 UTC
Permalink
Follow-up Comment #13, bug #46986 (project grub):

Well, when I disable strip command in genmod.sh for all_video.mod it contains
these symbols (same as all_video.module):
SYMBOL TABLE:
00000000 l d .text 00000000 .text
00000000 l d .data 00000000 .data
00000000 l d .module_license 00000000 .module_license
00000000 l d .bss 00000000 .bss
00000000 l d .note.GNU-stack 00000000 .note.GNU-stack
00000000 l d .debug_aranges 00000000 .debug_aranges
00000000 l d .debug_info 00000000 .debug_info
00000000 l d .debug_abbrev 00000000 .debug_abbrev
00000000 l d .debug_line 00000000 .debug_line
00000000 l d .debug_str 00000000 .debug_str
00000000 l df *ABS* 00000000 fake_module.c
00000000 l O .module_license 0000000f grub_module_license
00000000 l d .moddeps 00000000 .moddeps
00000000 l d .modname 00000000 .modname


_______________________________________________________

Reply to this item at:

<http://savannah.gnu.org/bugs/?46986>

_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
Kostya Berger
2016-01-27 21:28:48 UTC
Permalink
Follow-up Comment #14, bug #46986 (project grub):

Sorry, distorted output here.

_______________________________________________________

Reply to this item at:

<http://savannah.gnu.org/bugs/?46986>

_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
Kostya Berger
2016-01-27 21:37:37 UTC
Permalink
Follow-up Comment #15, bug #46986 (project grub):

Here's objdump output for all_video.mod that builds with strip section removed
in genmod.sh (for this particular module):
LC_ALL=C objdump -x all_video.mod

all_video.mod: file format elf32-i386-freebsd
all_video.mod
architecture: i386, flags 0x00000011:
HAS_RELOC, HAS_SYMS
start address 0x00000000

Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000000 00000000 00000000 00000034 2**0
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .data 00000000 00000000 00000000 00000034 2**0
CONTENTS, ALLOC, LOAD, DATA
2 .module_license 0000000f 00000000 00000000 00000034 2**0
CONTENTS, ALLOC, LOAD, DATA
3 .bss 00000000 00000000 00000000 00000043 2**0
ALLOC
4 .note.GNU-stack 00000000 00000000 00000000 00000043 2**0
CONTENTS, READONLY
5 .debug_aranges 00000018 00000000 00000000 00000043 2**0
CONTENTS, RELOC, READONLY, DEBUGGING
6 .debug_info 0000042a 00000000 00000000 0000005b 2**0
CONTENTS, RELOC, READONLY, DEBUGGING
7 .debug_abbrev 0000011b 00000000 00000000 00000485 2**0
CONTENTS, READONLY, DEBUGGING
8 .debug_line 0000007b 00000000 00000000 000005a0 2**0
CONTENTS, READONLY, DEBUGGING
9 .debug_str 00000779 00000000 00000000 0000061b 2**0
CONTENTS, READONLY, DEBUGGING
10 .moddeps 00000021 00000000 00000000 00000d94 2**0
CONTENTS, READONLY
11 .modname 0000000a 00000000 00000000 00000db5 2**0
CONTENTS, READONLY
SYMBOL TABLE:
00000000 l d .text 00000000 .text
00000000 l d .data 00000000 .data
00000000 l d .module_license 00000000 .