I don't know if the default for the AmigaOS 4.x port of strip was ever changed, but 15 years ago on AmigaOS 4.x only using "strip --strip-unneeded" worked.
It works as expected in adtools version, with all the flags, and even "--strip-unneeded-rel-relocs" works for us in adtools version.
If it does, what else should be the problem in https://github.com/migthymax/binutils-gdb/issues/2 ? Original "strip -s/--strip-all" removes all symbols, which of course can't work on AmigaOS and you have to use "strip --strip-unneeded" instead.
@joerg That issue report seems to apply to a cross compiler environment. I always use strip -s on my binaries and it indeed strips all symbols as far as possible. No idea why it can't work on amigaos. My binaries work just fine.
@geennaam An AmigaOS 4.x executable without the "_start" symbol can't work.
It's something different for libraries, devices, etc., started by struct Resident instead, in case you are using "strip -s" for example on your nvme.device.
I also use it on tools that come with my drivers. Like the hdmixer or Nvme diagnostics. So apparently strip -s strips all symbols that aren't strictly necessary from a functional pov.
That issue report seems to apply to a cross compiler environment.
It's not related to crocc or not cross-compiler , it's a new issue with new binutils which we need to fix.
Current public adtool's "strip" from 2.32 binutils works fine (and always works fine) be it cross or not cross-compilers of course. Issue above are about _new_ binutitils, with this _new_ issue.
@joerg Quote:
If it does, what else should be the problem in https://github.com/migthymax/binutils-gdb/issues/2 ? Original "strip -s/--strip-all" removes all symbols, which of course can't work on AmigaOS and you have to use "strip --strip-unneeded" instead.
Issue is that this is new binutils, which changed in major and minor parts, and we just didn't patch things properly everywhere to make it works : that what we need now, to find what we do wrong, or what we not do which causing such _new_ issue with this _new_ binutils.
I.e. there no problems with adtools, and with strip from adtools. What i point out now, is _new_ binutils (not from adtools), with _new_ issue in "strip" command. We probably just didn't do something correctly.
I see that adtools have some patches for strip: 0006-Introduced-strip-unneeded-rel-relocs.patch and 0007-Keep-symbols-for-stripped-sections.-This-is-importan.patch
Maybe this 0007 one is that one which should make it works.
.text must not be writable. If elf.library ignores it for code it may not be a problem, but if it doesn't and allocates the code in writable memory it's a problem.
Quote:
Read-only (.text, .rodata, ...) and writable (.sbss) sections mustn't be in the same segment. Executable (.text) and non-executable (everything else) sections mustn't be in the same segment either.
Both shouldn't be a problem to be fixed. Could you open a or two issues on the github project.
Both shouldn't be a problem to be fixed. Could you open a or two issues on the github project.
I create 2 tickets on github about, so Joerg have no needs to worry. Through, if you read my next post there, it seems it was like this all the time on amigaos4, from the beginning.
I build assembler test case (so just "as" and "ld" no "gcc" involved) , with binutils 2.14 from an old SDK, that what i have when i "readelf -e test_2_14":
$ ppc-amigaos-readelf -e test_2_14
ELF Header:
Magic: 7f 45 4c 46 01 02 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, big endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: PowerPC
Version: 0x1
Entry point address: 0x90
Start of program headers: 52 (bytes into file)
Start of section headers: 1468 (bytes into file)
Flags: 0x0
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 1
Size of section headers: 40 (bytes)
Number of section headers: 15
Section header string table index: 12
Section Headers:
[Nr] Name Type Addr Off Size ES Flg Lk Inf Al
[ 0] NULL 00000000 000000 000000 00 0 0 0
[ 1] .text PROGBITS 00000074 000074 00048c 00 WAX 0 0 4
[ 2] .rela.text RELA 00000000 000814 0002e8 0c 13 1 4
[ 3] .rodata PROGBITS 00000500 000500 000034 01 AMS 0 0 4
[ 4] .__newlib_version PROGBITS 00000534 000534 000008 00 A 0 0 4
[ 5] .sdata2 PROGBITS 0000053c 00053c 000000 00 A 0 0 4
[ 6] .data PROGBITS 0000053c 00053c 000000 00 WA 0 0 1
[ 7] .ctors PROGBITS 0000053c 00053c 000008 00 WA 0 0 4
[ 8] .dtors PROGBITS 00000544 000544 000008 00 WA 0 0 4
[ 9] .sdata PROGBITS 0000054c 00054c 000000 00 WA 0 0 4
[10] .sbss NOBITS 0000054c 00054c 000024 00 WA 0 0 4
[11] .bss NOBITS 00000570 00054c 000000 00 WA 0 0 1
[12] .shstrtab STRTAB 00000000 00054c 00006e 00 0 0 1
[13] .symtab SYMTAB 00000000 000afc 000240 10 14 16 4
[14] .strtab STRTAB 00000000 000d3c 0000c1 00 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
L (link order), O (extra OS processing required), G (group), T (TLS),
C (compressed), x (unknown), o (OS specific), E (exclude),
D (mbind), v (VLE), p (processor specific)
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD 0x000074 0x00000074 0x00000074 0x004d8 0x004fc RWE 0x4
As far as i can see, it was the same : .text were even back then marked as writable, and the same was about readonly and writable sections being in one segment, same as executable and non-executable sections being in one segment as well.
That with bintuils 2.14 , from 2003.06.12. So it was like this always, then , and this is not issue because of which baserel stop working ?
At least from the look at dumps, i can't see that in 2.14 it elf files were constructed anyhow different for us.
With this ldscript used, the .text segment is AX. Once i use defaults (so some default ldscript), then, the .text segment is WAX. And does not matter what version of gcc/binutils i use, even on 2.14 it's the same : default ldscript = WAX, my own one = AX.
EDIT: I even tried to build test case with new binutils, but just with my own ldscript : and it's AX !
This is probably mean, that prebuild ldscripts (the default ones LD uses) are guilty of. Right ?
Edited by kas1e on 2023/8/11 18:58:16 Edited by kas1e on 2023/8/11 18:59:28 Edited by kas1e on 2023/8/11 19:01:43
@joerg That when you use _start (so no libc.a), with libc it's not important, but yeah, added for sake of tests and still issue the same: with default ldscripts WAX, with my own - AX.
@All Can anyone point me out where in adtools/binutils patches, the changes to "strip" were done, so by default it acts like "--strip-unneeded", and not like "-s" ? Just can't find such change in patches, but definitely strip acts like "--strip-unneeded" by default in adtools version.
Do you know why the __amigaos4__ and __SDA_BASE__ needs to kept? The __start__ is is clear to be kept, because it defines the entry point of the executable.
@MigthyMax Isn't __SDA_BASE__ the pointer to the small data (.sbss/.sdata)? If it isn't, it may be the pointer to the baserel data.
Not sure about __amigaos4__, maybe it's just checked to make sure an ELF file is an AmigaOS 4.x executable and not something else. There is no AmigaOS defined for the OS in ELF executables (EI_OSABI), AmigaOS is using UNIX SysV (0) instead.
Edit: __SDA_BASE__ is the small data pointer, from the amigaos.* linker scripts:
/* We want the small data sections together, so single-instruction offsets
can access them all, and initialized data all before uninitialized, so
we can shorten the on-disk segment size. */
.sdata :
{
_SDA_BASE_ = . + 0x8000;
*(.sdata .sdata.* .gnu.linkonce.s.*)
}
_edata = .; PROVIDE (edata = .);
__bss_start = .;
.sbss :
{
*(.dynsbss)
*(.sbss .sbss.* .gnu.linkonce.sb.*)
*(.scommon)
}
Of course, nobody should take my word for it - however, "readelf -l" on most (if not all) OS components will show this to be the case. Two segments, unless there is no rw data at all, in which case a single read-only executable segment (e.g. "C:Version").