grub-pe2elf
Hi,
On a recent discussion on IRC, Bean pointed out that grub-pe2elf is essentially a workaround for a bug in objcopy.
Bean explained that this bug is quite obvious. It seems Christian sent them a patch, but it hasn't been applied (I don't know if it was rejected, or just ignored, Christian could you explain?).
Back in 2007, Christian proposed an ad-hoc solution for converting from PE to ELF:
http://lists.gnu.org/archive/html/grub-devel/2007-11/msg00174.html
which was rejected (see my comment and Marco's reply).
Later in July 2008, Bean added grub-pe2elf to the repository.
I keep thinking the same I thought in 2007. I don't agree that we should add such workarounds just because objcopy has a bug. binutils is a GNU program. It is free software and community-maintained. If it has bugs, we should be working with them instead of reimplementing their work.
First of all, I'm worried that we have discussions to decide things and they are later forgotten or ignored. Bean, please can you provide some explanation on what happened?
Also, I think this commit should be reverted (at least the part that adds grub-pe2elf). Also, I'd like to hear input on what happened with Christian's binutils patch, why it wasn't applied, etc.
Nevertheless, it's not an obligation for us to support win32. As long as we can do it sanely, I'm fine with it, but I don't want to see GRUB dragged into a situation in which we need to preserve win32 support at all costs.
Our primary target are GNU-based systems, as well as other free software systems, specially those that rely on GRUB as their default bootloader.
Signature · 5 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
Hi Robert,
Quoted 4 lines · Robert Millan
On a recent discussion on IRC, Bean pointed out that grub-pe2elf is essentially a workaround for a bug in objcopy.
It is essentially a limitation of BFD: The object format specific backends are apparently not implemented such that conversion between different relocation formats is supported.
In particular, a relocation 'addend' (-4 in this case) is lost during conversion if source or target relocation format do not support it as separate field. Some conversions may work. PE -> ELF does not work, the problem is in both backends in this case.
Quoted 5 lines
Bean explained that this bug is quite obvious. It seems Christian sent them a patch, but it hasn't been applied (I don't know if it was rejected, or just ignored, Christian could you explain?).
The patch was actually an ad-hoc approach to fix it in objcopy itself for the PE->ELF case only:
http://sourceware.org/ml/binutils/2007-10/msg00302.html
A generic solution which would have more chances to get accepted would require substantial work in BFD itself. Conversion between relocation formats is apparently rarely needed. A related bugzilla entry was reopened in 2005 and is idle since then:
http://sourceware.org/bugzilla/show_bug.cgi?id=970
Quoted 3 lines
Later in July 2008, Bean added grub-pe2elf to the repository.
Yes, and I really appreciated this :-)
Quoted 6 lines
First of all, I'm worried that we have discussions to decide things and they are later forgotten or ignored. Bean, please can you provide some explanation on what happened?
Also, I think this commit should be reverted (at least the part that adds grub-pe2elf).
I would regret this. Then you could also revert all my Cygwin related additions (some also included in Bean's r1726) because these no longer make much sense unless someone fixes BFD or maintains a ELF toolchain for Cygwin.
Quoted 5 lines
Nevertheless, it's not an obligation for us to support win32. As long as we can do it sanely, I'm fine with it, but I don't want to see GRUB dragged into a situation in which we need to preserve win32 support at all costs.
$ find grub2 -type f -name '*.[ch]' | xargs cat | wc -l 128175
$ cat grub2/util/grub-pe2elf.c | wc -l 521
0.4% of the total LoC is IMO less than 'all costs' :-)
Signature · 2 lines
Regards Christian Franke
Quoted 11 lines · Christian Franke
Quoted 6 lines
First of all, I'm worried that we have discussions to decide things and they are later forgotten or ignored. Bean, please can you provide some explanation on what happened?
Also, I think this commit should be reverted (at least the part that adds grub-pe2elf).
I would regret this. Then you could also revert all my Cygwin related additions (some also included in Bean's r1726) because these no longer make much sense unless someone fixes BFD or maintains a ELF toolchain for Cygwin.
But we supported Cygwin before grub-pe2elf. What has changed?
Signature · 5 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
Quoted 6 lines · Robert Millan
Quoted 4 lines · Christian Franke
Quoted 4 lines
First of all, I'm worried that we have discussions to decide things and they are later forgotten or ignored. Bean, please can you provide some explanation on what happened?
Quoted 9 lines
Quoted 5 lines
Quoted 3 lines
Also, I think this commit should be reverted (at least the part that adds grub-pe2elf).
I would regret this. Then you could also revert all my Cygwin related additions (some also included in Bean's r1726) because these no longer make much sense unless someone fixes BFD or maintains a ELF toolchain for Cygwin.
But we supported Cygwin before grub-pe2elf. What has changed?
Since ~r1584, util/grub-* could be build and run on Cygwin. Commit r1726 added support to build kernel and modules on Cygwin.
Signature · 2 lines
Regards, Christian Franke
Quoted 15 lines · Christian Franke
Quoted 14 lines · Robert Millan
Quoted 11 lines · Christian Franke
Quoted 6 lines
First of all, I'm worried that we have discussions to decide things and they are later forgotten or ignored. Bean, please can you provide some explanation on what happened?
Also, I think this commit should be reverted (at least the part that adds grub-pe2elf).
I would regret this. Then you could also revert all my Cygwin related
additions (some also included in Bean's r1726) because these no
longer make much sense unless someone fixes BFD or maintains a ELF toolchain for Cygwin.
Quoted 6 lines
Quoted 3 lines
But we supported Cygwin before grub-pe2elf. What has changed?
Since ~r1584, util/grub-* could be build and run on Cygwin. Commit r1726 added support to build kernel and modules on Cygwin.
There has to be more to it. I know you were using GRUB on Cygwin before that commit. Was this kludge being used since the beginning? What are the other options?
Signature · 5 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
Quoted 8 lines · Robert Millan
Quoted 4 lines · Christian Franke
Since ~r1584, util/grub-* could be build and run on Cygwin. Commit r1726 added support to build kernel and modules on Cygwin.
There has to be more to it. I know you were using GRUB on Cygwin before that commit. Was this kludge being used since the beginning?
I'm using GRUB on Cygwin since 'somewhat' before I announced the first patch 2007-10-16:
http://lists.gnu.org/archive/html/grub-devel/2007-10/msg00071.html
This version used the hack in grub's ELF-loader already discussed. It also contained some non Cygwin related fixes found during testing.
The grub2 package in the Cygwin distro from 2008-03-30 was based on this private branch merged to 1.96+epsilon.
Quoted 2 lines
What are the other options?
I don't know.
Waiting until someone fixes BFD or maintains a Linux cross-compiler package for Cygwin (which cannot be build OOTB, it requires build steps on Linux) may last until time_t wraps around and is IMO not an option :-)
Even the isolation of grub-pe2elf in a separate package would not help much, because the linker script and some support in the build system would be still needed in the grub2 tree.
Signature · 2 lines
Regards, Christian Franke
Quoted 26 lines · Christian Franke
Quoted 8 lines · Robert Millan
Quoted 4 lines · Christian Franke
Since ~r1584, util/grub-* could be build and run on Cygwin. Commit r1726 added support to build kernel and modules on Cygwin.
There has to be more to it. I know you were using GRUB on Cygwin before that commit. Was this kludge being used since the beginning?
I'm using GRUB on Cygwin since 'somewhat' before I announced the first patch 2007-10-16:
http://lists.gnu.org/archive/html/grub-devel/2007-10/msg00071.htmlThis version used the hack in grub's ELF-loader already discussed. It also contained some non Cygwin related fixes found during testing.
The grub2 package in the Cygwin distro from 2008-03-30 was based on this private branch merged to 1.96+epsilon.
Quoted 2 lines
What are the other options?
I don't know.
Quoted 9 lines
Waiting until someone fixes BFD or maintains a Linux cross-compiler package for Cygwin (which cannot be build OOTB, it requires build steps on Linux) may last until
time_twraps around and is IMO not an option :-)Even the isolation of grub-pe2elf in a separate package would not help much, because the linker script and some support in the build system would be still needed in the grub2 tree.
I personally think this is a hassle for nothing: we already have a working cygwin toolchain. While I acknowledge it's not perfect it works. And I propose not to touch it until it gives any maintainance or technical problem. When it does then we may consider dropping or limiting cygwin support. Until then this discussion is a waste of time (IMO)
Quoted 13 lines
--
Regards,
Christian Franke_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel
Signature · 4 lines
Regards Vladimir 'phcoder' Serbinenko Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
Quoted 6 lines · Vladimir 'phcoder' Serbinenko
I personally think this is a hassle for nothing: we already have a working cygwin toolchain. While I acknowledge it's not perfect it works. And I propose not to touch it until it gives any maintainance or technical problem. When it does then we may consider dropping or limiting cygwin support. Until then this discussion is a waste of time (IMO)
I agree that there is no urgent need to remove grub-pe2elf (although the issue might come up essentially). However, it's not so much a technical problem as an issue of trust.
Committing code against the wish of maintainers should not be permitted. Those who do it should lose commit access. They are welcome to contribute, but their patches will need to be committed by others.
I haven't seen any apology or explanation in this thread.
Signature · 2 lines
Regards, Pavel Roskin
Quoted 8 lines · Christian Franke
Quoted 3 lines
There has to be more to it. I know you were using GRUB on Cygwin before that commit. Was this kludge being used since the beginning?
I'm using GRUB on Cygwin since 'somewhat' before I announced the first patch 2007-10-16:
http://lists.gnu.org/archive/html/grub-devel/2007-10/msg00071.html
Quoted 5 lines
This version used the hack in grub's ELF-loader already discussed. It also contained some non Cygwin related fixes found during testing.
The grub2 package in the Cygwin distro from 2008-03-30 was based on this private branch merged to 1.96+epsilon.
Understood.
Quoted 6 lines
Quoted 1 line
What are the other options?
I don't know.
Waiting until someone fixes BFD or maintains a Linux cross-compiler package for Cygwin
I don't understand what you mean about a "Linux cross-compiler":
- Why a compiler? AFAICT, the problem here is assembly/linkage rather than compiling. binutils should suffice.
- It's not really "Linux", just generic ELF support (i.e.
i386-pc-elf rather than i386-pc-linux-gnu).
- It's not exactly "cross". I think something like --enable-targets=i386-pc-elf when building binutils should work just fine. This produces an "ld" that understands multiple formats (-m switch). Have you tried this?
Signature · 5 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
Quoted 11 lines · Pavel Roskin
Quoted 6 lines · Vladimir 'phcoder' Serbinenko
I personally think this is a hassle for nothing: we already have a working cygwin toolchain. While I acknowledge it's not perfect it works. And I propose not to touch it until it gives any maintainance or technical problem. When it does then we may consider dropping or limiting cygwin support. Until then this discussion is a waste of time (IMO)
I agree that there is no urgent need to remove grub-pe2elf (although the issue might come up essentially).
Indeed, now that we're in this situation, we can't revert this without causing major inconvenience on Cygwin users. We might still do it, but I'd rather explore the other possibilities first.
Quoted 8 lines
However, it's not so much a technical
problem as an issue of trust.Committing code against the wish of maintainers should not be permitted. Those who do it should lose commit access. They are welcome to contribute, but their patches will need to be committed by others.
I haven't seen any apology or explanation in this thread.
Yes, this is what worries me the most.
Anyhow, now that we've made our point, and everyone knows the drill, I hope that this kind of things don't happen again.
Signature · 5 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
Quoted 6 lines · Robert Millan
I don't understand what you mean about a "Linux cross-compiler":
- Why a compiler? AFAICT, the problem here is assembly/linkage rather than compiling. binutils should suffice.
Unfortunately this is not true:
Some assembly language directives generated by gcc differ between PE and ELF. An ELF 'gas' does not accept assembly output from a PE 'gcc' and vice versa. The whole toolchain must support ELF.
Quoted 4 lines
- It's not really "Linux", just generic ELF support (i.e.
i386-pc-elf rather than i386-pc-linux-gnu).
OK :-)
Quoted 6 lines
- It's not exactly "cross". I think something like --enable-targets=i386-pc-elf when building binutils should work just fine. This produces an "ld" that understands multiple formats (-m switch). Have you tried this?
Cygwin binutils are build with this option:
$ ld --help ... ld: supported targets: pe-i386 pei-i386 elf32-i386 elf32-little elf32-big srec symbolsrec tekhex binary ihex
But this does not help because ld refuses to build ELF output from PE input. So you need an ELF gas. Which requires an ELF gcc...
I already described that here:
http://lists.gnu.org/archive/html/grub-devel/2007-11/msg00233.html
Signature · 2 lines
Regards, Christian Franke
Quoted 7 lines · Robert Millan
Quoted 5 lines · Pavel Roskin
Committing code against the wish of maintainers should not be permitted. Those who do it should lose commit access. They are welcome to contribute, but their patches will need to be committed by others.
I agree...
Quoted 4 lines
Quoted 2 lines
I haven't seen any apology or explanation in this thread.
... but I will not apologize simply because I did not commit the grub-pe2elf patch.
Quoted 3 lines
Yes, this is what worries me the most.
I'm somewhat worried that these complaints are delayed by more than a year Commit 1726 is from 2008-07-24, start was here:
http://lists.gnu.org/archive/html/grub-devel/2008-07/msg00452.html
Signature · 2 lines
Regards, Christian Franke
Quoted 2 lines · Christian Franke
I'm somewhat worried that these complaints are delayed by more than a year
I noticed by chance. We were talking about something else on IRC, when Bean mentioned that objcopy has bug when converting from PE to ELF. Later he pointed at the thread in which this was discussed.
We can't expect _anyone_ to be continously watching every commit and checking the corresponding discussions related to it that happened in the few months that precede the commit. If someone had to do that, that person wouldn't have time to do anything else.
Signature · 5 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."