grub4dos icon indicating copy to clipboard operation
grub4dos copied to clipboard

fix gcc 7,8,9 errors

Open memoarfaa opened this issue 1 year ago • 10 comments

The pull request was accidentally done in visual studio code, while I'm still working on some issues in the private repository in my local build development environment, but since it's done let's discuss this

memoarfaa avatar Jul 18 '22 12:07 memoarfaa

gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0 GNU objcopy (GNU Binutils for Ubuntu) 2.34 ./build ERROR: checking whether objcopy works for absolute addresses... configure: error: gcc cannot link at address 2000

a1ive avatar Jul 18 '22 12:07 a1ive

yes

memoarfaa avatar Jul 18 '22 13:07 memoarfaa

gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0 GNU objcopy (GNU Binutils for Ubuntu) 2.34 ./build ERROR: checking whether objcopy works for absolute addresses... configure: error: gcc cannot link at address 2000

@a1ive I don't understand what do you mean First do you mean you tried and failed? How is that version that I work on most of the time is the same version !!! Secondly, I do not use build script I use ./autogen.sh to update make files also

I stopped development with gcc,make,grub and grub4dos from some time ago because i was busy with my job in .net core and .net framework but now I'm here so now I working in modern development environment parallel to it https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&cad=rja&uact=8&ved=2ahUKEwiO5u6zzoT5AhWYhM4BHbC3BHQQFnoECBUQAQ&url=https%3A%2F%2Fcode.visualstudio.com%2F&usg=AOvVaw15O90sm1ios8AUpw56hCml in windows 10 with https://docs.microsoft.com/en-us/windows/wsl/install

you can name it The Old New Thing https://devblogs.microsoft.com/oldnewthing/author/oldnewthing I will upload mp4 record here beside this conversation until that I uploaded the patches here you can try it tested with "gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) GNU objcopy (GNU objcopy (GNU Binutils for Ubuntu) 2.30)" "gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0 GNU objcopy (GNU Binutils for Ubuntu) 2.34" "gcc version 10.2.1 20210110 (Debian 10.2.1-6) GNU objcopy (GNU Binutils for Debian) 2.35.2" still some patches not uploaded yet

objcopy and no-pie.zip

see 1- https://nanxiao.me/en/gccs-enable-enable-default-pie-option-make-you-stuck-at-relocation-r_x86_64_32s-against-error/

2- https://www.linuxquestions.org/questions/linux-software-2/configure-error-grub-requires-a-working-absolute-objcopy%3B-upgrade-your-binutils-644377/

memoarfaa avatar Jul 19 '22 09:07 memoarfaa

I forget this for 0.4.6a branch only efi branches still need some work

memoarfaa avatar Jul 19 '22 11:07 memoarfaa

I forget this for 0.4.6a branch only efi branches still need some work

git clone --depth 1 -b build https://github.com/memoarfaa/grub4dos
cd grub4dos
git log
./autogen.sh

1 2

a1ive avatar Jul 19 '22 13:07 a1ive

I saw 179756497-a9ec1722-30d7-4ab9-8b83-c434888120f1

2022-07-19_16-50-28

objcopy doesn't accept build-id=none so objcopy required .note.gnu.build-id for debugging can you please edit stage2/Makefile.am

$(AM_V_OBJCOPY) -O binary $< $@

replace with $(AM_V_OBJCOPY) -O binary -R .note -R .comment -R .note.gnu.build-id $< $@

memoarfaa avatar Jul 19 '22 14:07 memoarfaa

It doesn't work either.

diff --git a/stage2/Makefile.am b/stage2/Makefile.am
index 0bfd33b..3efdd46 100644
--- a/stage2/Makefile.am
+++ b/stage2/Makefile.am
@@ -167,7 +167,7 @@ badgrubstart.S: a20.inc
 # General rule for making a raw binary.
 SUFFIXES = .exec
 %: %.exec$(EXEEXT)
-       $(AM_V_OBJCOPY) -O binary $< $@
+       $(AM_V_OBJCOPY) -O binary -R .note -R .comment -R .note.gnu.build-id $< $@
        $(AM_V_at)if [ $@ = pre_stage2 ]; then dd if=pre_stage2 of=pre_stage2_fullsize bs=65536 skip=48 2>/dev/null || echo "DD failed!" ;fi
        $(AM_V_at)if [ $@ = pre_stage2 ]; then sed -e "1s/^\x00*//" pre_stage2_fullsize > pre_stage2_tail ;fi
        $(AM_V_at)if [ $@ = pre_stage2 ]; then set dummy `ls -l pre_stage2_fullsize`; set $$6 `ls -l pre_stage2_tail`; if [ $$1 -le $$6 ]; then set `cmp pre_stage2_fullsize /dev/zero` ; while [ "$$1" != "" ]; do t1="$${1%%[^0-9]*}"; if [ "$$t1" != "" ]; then if [ "$$t1" -gt 2000 ]; then t1=`expr $$t1 - 1`; dd if=pre_stage2_fullsize of=pre_stage2_tail bs=1 skip=$$t1  2>/dev/null || echo "DD failed!" ; break; fi; fi; shift; done; fi; fi
diff --git a/stage2/Makefile.in b/stage2/Makefile.in
index c14e988..e2b9799 100644
--- a/stage2/Makefile.in
+++ b/stage2/Makefile.in
@@ -1840,7 +1840,7 @@ dosstart.S: a20.inc
 badgrubstart.S: a20.inc
        touch badgrubstart.S
 %: %.exec$(EXEEXT)
-       $(AM_V_OBJCOPY) -O binary $< $@
+       $(AM_V_OBJCOPY) -O binary -R .note -R .comment -R .note.gnu.build-id $< $@
        $(AM_V_at)if [ $@ = pre_stage2 ]; then dd if=pre_stage2 of=pre_stage2_fullsize bs=65536 skip=48 2>/dev/null || echo "DD failed!" ;fi
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
/root/grub4dos/missing: Unknown `--is-lightweight' option
Try `/root/grub4dos/missing --help' for more information
configure: WARNING: 'missing' script is too old or missing
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking whether make supports the include directive... yes (GNU style)
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking dependency style of gcc... gcc3
checking dependency style of gcc... gcc3
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking whether to enable maintainer-specific portions of Makefiles... yes
checking for perl... /usr/bin/perl
checking for gcc... (cached) gcc
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking whether gcc understands -c and -o together... (cached) yes
checking dependency style of gcc... (cached) gcc3
checking dependency style of gcc... (cached) gcc3
checking for ranlib... ranlib
checking whether optimization for size works... yes
checking whether gcc has -fno-stack-protector... yes
checking whether gcc has -fno-reorder-functions... yes
checking whether -Wundef works... yes
checking whether -falign-loops works... yes
checking whether linker accepts `--build-id=none'... no
checking checking whether linker has  `-no-pie'... no
checking for objcopy... objcopy
checking if C symbols get an underscore after compilation... no
checking whether objcopy works for absolute addresses... configure: error: gcc cannot link at address 2000

a1ive avatar Jul 20 '22 01:07 a1ive

@a1ive I found the problem occurred only if your operating system is server edition so Ubuntu Desktop no problem but Ubuntu server still has problem I will try to fix it

memoarfaa avatar Jul 21 '22 17:07 memoarfaa

@a1ive I didn't really know who you were, so please excuse me I made sure it was a test from you So please tell me why the development environment in Windows has a problem http://bbs.c3.wuyou.net/forum.php?mod=redirect&goto=findpost&ptid=427888&pid=4426541&fromuid=501600 And I'll just try to follow some of your instructions if you want to guide me grldr.zip

memoarfaa avatar Jul 24 '22 23:07 memoarfaa

@a1ive I found the problem occurred only if your operating system is server edition so Ubuntu Desktop no problem but Ubuntu server still has problem I will try to fix it

I use wsl (Ubuntu 20.04.4 LTS on Windows 10 x86_64).

a1ive avatar Jul 25 '22 13:07 a1ive

@a1ive I update my branch 0.4.6a and open other pull request can you try it I tested it in Ubuntu 22.04.1 LTS on Windows 10 x86_64 with gcc 11, gcc 10 and gcc 9

in Ubuntu wsl type

sudo apt-get -y update

sudo apt install -y gcc gcc-multilib nasm upx upx-ucl p7zip-full autoconf automake make patch binutils-dev liblzma-dev syslinux isolinux genisoimage

git clone --depth 1 -b 0.4.6a https://github.com/memoarfaa/grub4dos cd grub4dos make

memoarfaa avatar Jan 15 '23 02:01 memoarfaa