-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
linker section overlap #171
Comments
using gcc 4.8 does not seem to be possible anymore due to inline assembly syntax errors, using version 8 does cause similar issues though sections are offset by a couple of bytes suggesting less size efficient code to be generated possibly. trying verison 10 now |
Thank you for opening this up. I tried to replicate the issue, but failed to do so. I used Ubuntu 24.04 on a native s390 system (LPAR) with gcc 13.2.0 - worked I tried cross compiling the boot loader from x86 on a Fedora 40 as well still no problems. Let me check if I find a gcc13.3.0 How does your build environment looks like? |
It seems like I can get this to run under debian using
the nix counterpart looks like this:
|
update: using gcc14 seems to work but 13 nor 10 nor 12 do, this sort of is expected in the sense that I expected this to somehow depend on compiler internal/optimisation/flag interpretation foo. As for now under nix I have a construct like seen below (please note that its incomplete and the host architecture is hardcoded, also the makefile is patched to only build zipl not {
inputs = {
nixpkgs_.url = "github:nixos/nixpkgs/nixpkgs-unstable";
utils.url = "github:numtide/flake-utils";
nixpkgs = {
url = "github:nixos/nixpkgs;
ref = "staging";
type = "git";
};
s390-tools = {
url = "ssh://[email protected]/ibm-s390-linux/s390-tools";
flake = false;
type = "git";
};
};
outputs = { self, nixpkgs, utils, naersk , s390-tools, nixpkgs_}:
utils.lib.eachSystem ["x86_64-linux" "s390x-linux"] (system:
let
_pkgs = import nixpkgs_ { system="x86_64-linux"; };
pkgs = import nixpkgs {
# todo inherit system instead and all
system = "x86_64-linux";
crossSystem = { gcc.arch = "z10"; config = "s390x-unknown-linux-gnu"; };
};
in
{
defaultPackage = pkgs.gcc14Stdenv.mkDerivation {
#defaultPackage = pkgs.stdenv.mkDerivation {
name = "s390-tools";
version = "2.33.1";
src = "${s390-tools}";
buildInputs = with pkgs; [
systemd.dev
cryptsetup.dev
net-snmp.dev
#glibc.static.out
#ncurses.dev
fuse3
#pkgs.cargo
openssl_legacy
#curl.dev
#json_c.dev
#libxml2.dev
];
hardeningDisable = [ "all" ];
patchPhase = with _pkgs; ''
patchShebangs --build .
substituteInPlace \
common.mak --replace-fail "override SHELL := /bin/bash" "override SHELL := ${bash}/bin/bash"
substituteInPlace Makefile \
--replace-fail "LIB_DIRS = libvtoc libzds libdasd libccw libvmcp libekmfweb \\" "LIB_DIRS = #\\" \
--replace-fail "TOOL_DIRS = zipl zdump fdasd dasdfmt dasdview tunedasd \\" "TOOL_DIRS = zipl #\\"
'';
buildPhase = ''
make V=1 -j 1 HOST_ARCH=s390x BUILD_ARCH=x86_64-linux CROSS_COMPILE=s390x-unknown-linux-gnu- \
HAVE_OPENSSL=0 \
HAVE_CURL=0 \
HAVE_CARGO=0 \
HAVE_GLIB=0 \
HAVE_GLIB2=0 \
HAVE_PFM=0 \
'';
installPhase = ''
mkdir -p $out
make V=1 -j 1 HOST_ARCH=s390x BUILD_ARCH=x86_64-linux CROSS_COMPILE=s390x-unknown-linux-gnu- DEST_DIR=$out \
HAVE_OPENSSL=0 \
HAVE_CURL=0 \
HAVE_CARGO=0 \
HAVE_GLIB=0 \
HAVE_GLIB2=0 \
HAVE_PFM=0 \
'';
};
}
);
} |
so essentially in nix terms setting defaultPackage = pkgs.gcc14Stdenv.mkDerivation {}; does seem to work but setting defaultPackage = pkgs.gcc13Stdenv.mkDerivation {} does not. The version set there indirecty affects the source thats being used for building gcc as seen here |
Can you please provide the corresponding .map file? You can create them by adding e.g.
Hopefully they will be generated, even if the linking fails :/ |
eckd2dump_mv.exec.map :
|
it seems like this is the last time gcc was called when linking before failing, thus the map provided above is the result of that last call and the files did indeed not get deleted (assuming nix develop's shell is used rather than nix build ofc)
I will also attach the gcc 14 one which works below:
thus the diff 45c45
< .text 0x0000000000002048 0x2b7c
---
> .text 0x0000000000002048 0x2c04
52c52
< .text 0x00000000000024e8 0x918 stage2dump.o
---
> .text 0x00000000000024e8 0x938 stage2dump.o
56,110c56,110
< 0x0000000000002948 create_ida_list
< 0x00000000000029a0 df_s390_em_page_init
< 0x00000000000029e0 panic_notify
< 0x0000000000002a10 start
< .text 0x0000000000002e00 0x390 cio.o
< 0x0000000000002ec0 store_subchannel
< 0x0000000000002ed8 io_irq_enable
< 0x0000000000002f08 io_irq_disable
< 0x0000000000002f30 start_io
< 0x00000000000030b0 set_device
< .text 0x0000000000003190 0x928 eckd2dump.o
< 0x0000000000003760 writeblock
< 0x00000000000037c0 readblock
< 0x0000000000003820 write_addr_range
< 0x0000000000003938 write_dump_segment
< 0x00000000000039c8 stage2dump_eckd_init
< .text 0x0000000000003ab8 0xa38 libc.o
< 0x0000000000003ab8 memset
< 0x0000000000003ad8 memcpy
< 0x0000000000003af8 memmove
< 0x0000000000003b48 strcpy
< 0x0000000000003b78 strlen
< 0x0000000000003b98 strlcpy
< 0x0000000000003c08 strcat
< 0x0000000000003c50 strncmp
< 0x0000000000003c98 strchr
< 0x0000000000003cb8 strhash
< 0x0000000000003d08 load_wait_psw
< 0x0000000000003d70 initialize
< 0x0000000000003dc8 libc_stop
< 0x00000000000042a0 snprintf
< 0x00000000000042f0 printf
< 0x0000000000004368 get_zeroed_page
< 0x0000000000004428 free_page
< 0x0000000000004480 pgm_check_handler_fn
< .text 0x00000000000044f0 0x68 ebcdic.o
< 0x00000000000044f0 ebcdic_strtoul
< .text 0x0000000000004558 0x650 sclp.o
< 0x0000000000004558 sclp_wait_for_int
< 0x0000000000004638 start_sclp
< 0x00000000000046b8 sclp_setup
< 0x00000000000047a8 sclp_print
< 0x0000000000004900 sclp_read_info
< 0x0000000000004990 sclp_param
< 0x00000000000049f0 sclp_read
< .text 0x0000000000004ba8 0x1c entry.o
< 0x0000000000004ba8 pgm_check_handler
< 0x0000000000004bc4 __ex_table_start = .
<
< .iplt 0x0000000000004bc4 0x0
< .iplt 0x0000000000004bc4 0x0 eckd2dump_mv.o
<
< .fixup 0x0000000000004bc4 0x40
< .fixup 0x0000000000004bc4 0x30 stage2dump.o
< .fixup 0x0000000000004bf4 0x10 eckd2dump.o
---
> 0x0000000000002960 create_ida_list
> 0x00000000000029b8 df_s390_em_page_init
> 0x00000000000029f8 panic_notify
> 0x0000000000002a28 start
> .text 0x0000000000002e20 0x390 cio.o
> 0x0000000000002ee0 store_subchannel
> 0x0000000000002ef8 io_irq_enable
> 0x0000000000002f28 io_irq_disable
> 0x0000000000002f50 start_io
> 0x00000000000030d0 set_device
> .text 0x00000000000031b0 0x948 eckd2dump.o
> 0x0000000000003798 writeblock
> 0x00000000000037f8 readblock
> 0x0000000000003858 write_addr_range
> 0x0000000000003970 write_dump_segment
> 0x0000000000003a08 stage2dump_eckd_init
> .text 0x0000000000003af8 0xa70 libc.o
> 0x0000000000003af8 memset
> 0x0000000000003b18 memcpy
> 0x0000000000003b38 memmove
> 0x0000000000003b88 strcpy
> 0x0000000000003bb8 strlen
> 0x0000000000003bd8 strlcpy
> 0x0000000000003c48 strcat
> 0x0000000000003c90 strncmp
> 0x0000000000003cd8 strchr
> 0x0000000000003cf8 strhash
> 0x0000000000003d48 load_wait_psw
> 0x0000000000003db0 initialize
> 0x0000000000003e00 libc_stop
> 0x0000000000004308 snprintf
> 0x0000000000004358 printf
> 0x00000000000043d0 get_zeroed_page
> 0x0000000000004488 free_page
> 0x00000000000044e8 pgm_check_handler_fn
> .text 0x0000000000004568 0x68 ebcdic.o
> 0x0000000000004568 ebcdic_strtoul
> .text 0x00000000000045d0 0x660 sclp.o
> 0x00000000000045d0 sclp_wait_for_int
> 0x00000000000046b0 start_sclp
> 0x0000000000004730 sclp_setup
> 0x0000000000004820 sclp_print
> 0x0000000000004980 sclp_read_info
> 0x0000000000004a18 sclp_param
> 0x0000000000004a78 sclp_read
> .text 0x0000000000004c30 0x1c entry.o
> 0x0000000000004c30 pgm_check_handler
> 0x0000000000004c4c __ex_table_start = .
>
> .iplt 0x0000000000004c4c 0x0
> .iplt 0x0000000000004c4c 0x0 eckd2dump_mv.o
>
> .fixup 0x0000000000004c4c 0x40
> .fixup 0x0000000000004c4c 0x30 stage2dump.o
> .fixup 0x0000000000004c7c 0x10 eckd2dump.o
112c112
< .ex_table 0x0000000000004c04 0x88
---
> .ex_table 0x0000000000004c8c 0x88
114,116c114,116
< .ex_table 0x0000000000004c04 0x68 stage2dump.o
< .ex_table 0x0000000000004c6c 0x20 eckd2dump.o
< 0x0000000000004c8c __ex_table_stop = .
---
> .ex_table 0x0000000000004c8c 0x68 stage2dump.o
> .ex_table 0x0000000000004cf4 0x20 eckd2dump.o
> 0x0000000000004d14 __ex_table_stop = .
118c118
< .rodata 0x0000000000004c90 0x40
---
> .rodata 0x0000000000004d18 0x48
120,122c120,122
< .rodata 0x0000000000004c90 0x8 stage2dump.o
< .rodata 0x0000000000004c98 0x10 libc.o
< .rodata 0x0000000000004ca8 0x28 sclp.o
---
> .rodata 0x0000000000004d18 0x8 stage2dump.o
> .rodata 0x0000000000004d20 0x18 libc.o
> .rodata 0x0000000000004d38 0x28 sclp.o
124c124
< .rodata.str1.2 0x0000000000004cd0 0x240
---
> .rodata.str1.2 0x0000000000004d60 0x240
126c126
< 0x0000000000004cd0 0x240 eckd2dump_mv.o
---
> 0x0000000000004d60 0x240 eckd2dump_mv.o
129c129
< 0x0000000000004f10 0x15c stage2dump.o
---
> 0x0000000000004fa0 0x15c stage2dump.o
131c131
< 0x0000000000004f10 0x32 cio.o
---
> 0x0000000000004fa0 0x32 cio.o
133c133
< 0x0000000000004f10 0x4e eckd2dump.o
---
> 0x0000000000004fa0 0x4e eckd2dump.o
135,137c135,143
< .rela.dyn 0x0000000000004f10 0x0
< .rela.iplt 0x0000000000004f10 0x0 eckd2dump_mv.o
< .rela.text 0x0000000000004f10 0x0 eckd2dump_mv.o
---
> .rodata.cst8 0x0000000000004fa0 0x48
> .rodata.cst8 0x0000000000004fa0 0x8 eckd2dump_mv.o
> .rodata.cst8 0x0000000000004fa8 0x40 libc.o
>
> .rela.dyn 0x0000000000004fe8 0x0
> .rela.iplt 0x0000000000004fe8 0x0 eckd2dump_mv.o
> .rela.rodata.cst8
> 0x0000000000004fe8 0x0 eckd2dump_mv.o
> .rela.rodata 0x0000000000004fe8 0x0 eckd2dump_mv.o
139c145
< .data 0x0000000000004f10 0x24
---
> .data 0x0000000000004fe8 0x24
141,150c147,156
< .data 0x0000000000004f10 0x4 eckd2dump_mv.o
< .data 0x0000000000004f14 0x0 head.o
< .data 0x0000000000004f14 0x0 stage2dump.o
< .data 0x0000000000004f14 0x0 cio.o
< .data 0x0000000000004f14 0x20 eckd2dump.o
< .data 0x0000000000004f34 0x0 libc.o
< .data 0x0000000000004f34 0x0 ebcdic.o
< .data 0x0000000000004f34 0x0 sclp.o
< .data 0x0000000000004f34 0x0 entry.o
< 0x0000000000004f34 __stage2_params = .
---
> .data 0x0000000000004fe8 0x4 eckd2dump_mv.o
> .data 0x0000000000004fec 0x0 head.o
> .data 0x0000000000004fec 0x0 stage2dump.o
> .data 0x0000000000004fec 0x0 cio.o
> .data 0x0000000000004fec 0x20 eckd2dump.o
> .data 0x000000000000500c 0x0 libc.o
> .data 0x000000000000500c 0x0 ebcdic.o
> .data 0x000000000000500c 0x0 sclp.o
> .data 0x000000000000500c 0x0 entry.o
> 0x000000000000500c __stage2_params = .
152,153c158,159
< .igot.plt 0x0000000000004f38 0x0
< .igot.plt 0x0000000000004f38 0x0 eckd2dump_mv.o
---
> .igot.plt 0x0000000000005010 0x0
> .igot.plt 0x0000000000005010 0x0 eckd2dump_mv.o
233c239
< .debug_info 0x0000000000000000 0xa624
---
> .debug_info 0x0000000000000000 0xa641
236,253c242,259
< .debug_info 0x0000000000001207 0x30e9 stage2dump.o
< .debug_info 0x00000000000042f0 0x1536 cio.o
< .debug_info 0x0000000000005826 0x1a37 eckd2dump.o
< .debug_info 0x000000000000725d 0x18b5 libc.o
< .debug_info 0x0000000000008b12 0x129 ebcdic.o
< .debug_info 0x0000000000008c3b 0x19c1 sclp.o
< .debug_info 0x000000000000a5fc 0x28 entry.o
<
< .debug_abbrev 0x0000000000000000 0x2133
< .debug_abbrev 0x0000000000000000 0x422 eckd2dump_mv.o
< .debug_abbrev 0x0000000000000422 0x14 head.o
< .debug_abbrev 0x0000000000000436 0x71e stage2dump.o
< .debug_abbrev 0x0000000000000b54 0x404 cio.o
< .debug_abbrev 0x0000000000000f58 0x5f8 eckd2dump.o
< .debug_abbrev 0x0000000000001550 0x5d8 libc.o
< .debug_abbrev 0x0000000000001b28 0xd0 ebcdic.o
< .debug_abbrev 0x0000000000001bf8 0x527 sclp.o
< .debug_abbrev 0x000000000000211f 0x14 entry.o
---
> .debug_info 0x0000000000001207 0x30e7 stage2dump.o
> .debug_info 0x00000000000042ee 0x153c cio.o
> .debug_info 0x000000000000582a 0x1a60 eckd2dump.o
> .debug_info 0x000000000000728a 0x1898 libc.o
> .debug_info 0x0000000000008b22 0x129 ebcdic.o
> .debug_info 0x0000000000008c4b 0x19ce sclp.o
> .debug_info 0x000000000000a619 0x28 entry.o
>
> .debug_abbrev 0x0000000000000000 0x20d9
> .debug_abbrev 0x0000000000000000 0x41c eckd2dump_mv.o
> .debug_abbrev 0x000000000000041c 0x14 head.o
> .debug_abbrev 0x0000000000000430 0x702 stage2dump.o
> .debug_abbrev 0x0000000000000b32 0x3ec cio.o
> .debug_abbrev 0x0000000000000f1e 0x5e1 eckd2dump.o
> .debug_abbrev 0x00000000000014ff 0x5ea libc.o
> .debug_abbrev 0x0000000000001ae9 0xd0 ebcdic.o
> .debug_abbrev 0x0000000000001bb9 0x50c sclp.o
> .debug_abbrev 0x00000000000020c5 0x14 entry.o
256c262
< 0x0000000000000000 0x2f49
---
> 0x0000000000000000 0x3221
260c266
< 0x0000000000000228 0x93a stage2dump.o
---
> 0x0000000000000228 0x958 stage2dump.o
262c268
< 0x0000000000000b62 0x375 cio.o
---
> 0x0000000000000b80 0x375 cio.o
264c270
< 0x0000000000000ed7 0xfe4 eckd2dump.o
---
> 0x0000000000000ef5 0xf7d eckd2dump.o
266c272
< 0x0000000000001ebb 0xa96 libc.o
---
> 0x0000000000001e72 0xd93 libc.o
268c274
< 0x0000000000002951 0x3c ebcdic.o
---
> 0x0000000000002c05 0x43 ebcdic.o
270c276
< 0x000000000000298d 0x5bc sclp.o
---
> 0x0000000000002c48 0x5d9 sclp.o
293c299
< 0x0000000000000000 0x328
---
> 0x0000000000000000 0x35c
295c301
< 0x0000000000000000 0x77 eckd2dump_mv.o
---
> 0x0000000000000000 0x7c eckd2dump_mv.o
297c303
< 0x0000000000000077 0x102 stage2dump.o
---
> 0x000000000000007c 0x106 stage2dump.o
299c305
< 0x0000000000000179 0x1c cio.o
---
> 0x0000000000000182 0x1c cio.o
301c307
< 0x0000000000000195 0xd1 eckd2dump.o
---
> 0x000000000000019e 0xc6 eckd2dump.o
303c309
< 0x0000000000000266 0x66 libc.o
---
> 0x0000000000000264 0x9c libc.o
305c311
< 0x00000000000002cc 0x5c sclp.o
---
> 0x0000000000000300 0x5c sclp.o
307,316c313,322
< .debug_line 0x0000000000000000 0x2e5f
< .debug_line 0x0000000000000000 0x523 eckd2dump_mv.o
< .debug_line 0x0000000000000523 0x53 head.o
< .debug_line 0x0000000000000576 0xb27 stage2dump.o
< .debug_line 0x000000000000109d 0x440 cio.o
< .debug_line 0x00000000000014dd 0x908 eckd2dump.o
< .debug_line 0x0000000000001de5 0x8cf libc.o
< .debug_line 0x00000000000026b4 0xb5 ebcdic.o
< .debug_line 0x0000000000002769 0x6a8 sclp.o
< .debug_line 0x0000000000002e11 0x4e entry.o
---
> .debug_line 0x0000000000000000 0x2efe
> .debug_line 0x0000000000000000 0x52f eckd2dump_mv.o
> .debug_line 0x000000000000052f 0x53 head.o
> .debug_line 0x0000000000000582 0xb40 stage2dump.o
> .debug_line 0x00000000000010c2 0x440 cio.o
> .debug_line 0x0000000000001502 0x90a eckd2dump.o
> .debug_line 0x0000000000001e0c 0x936 libc.o
> .debug_line 0x0000000000002742 0xb7 ebcdic.o
> .debug_line 0x00000000000027f9 0x6b7 sclp.o
> .debug_line 0x0000000000002eb0 0x4e entry.o
340c346
< .debug_frame 0x0000000000000000 0xaa8
---
> .debug_frame 0x0000000000000000 0xab0
345,347c351,353
< .debug_frame 0x00000000000005c0 0x2f8 libc.o
< .debug_frame 0x00000000000008b8 0x40 ebcdic.o
< .debug_frame 0x00000000000008f8 0x1b0 sclp.o
---
> .debug_frame 0x00000000000005c0 0x300 libc.o
> .debug_frame 0x00000000000008c0 0x40 ebcdic.o
> .debug_frame 0x0000000000000900 0x1b0 sclp.o
|
what sticks out right away is 45c45
< .text 0x0000000000002048 0x2b7c
---
> .text 0x0000000000002048 0x2c04 with Since the linker script mentioned above defines:
the
sections size affects what comes behind from my remote understanding of linker scripts
since judging by the diff |
comparing the
the gcc14 zipl libc's vsnprintf for example is troughout the object files when compared there is plenty of cases where the gcc13 version is bigger, while not by much it seems to add up regardless. But what I don't get is why this compiled for other people in the past just fine using older gcc versions ... |
update:
as you can see here |
Most likely no one used the bad combination, in Fedora we are now at z13 as the arch level, we were on zEC12 for a long time and on z10 before that. The booloader is logically space constrained so it might be affected by a bad compiler version & flags combination. You probably want to build for something newer even than z10 anyway, because there are unlikely any z10 systems still in active service. |
I see thanks
well I got a Z10 to toy around with :) specifically because z10's are no longer in service unlike newer models which makes it possible to own these unlike newer versions without spending more than most ppl earn |
Hey when building this from master as well as the most recent release (2.33.1) im getting issues like these:
regardless of wether im cross compiling it or "natively" compiling it using qemu binfmt.
So looking at:
s390-tools/zipl/boot/stage2.lds.S
Line 46 in d7b3196
and consequently changing some of the offsets there at "s390-tools/zipl/boot/stage2.lds.S" does seem to get zipl to compile but it obviously doesn't work properly afterwards then.
So I'm wondering what may be the cause for the .data section to overlap with
s390-tools/zipl/boot/stage2.lds.S
Line 49 in d7b3196
since the sections before like:
's position is relative to the starting point and previous section start + size. I take that as either .data , the params or .rotata and whats before being too big? And thus causing
.data
to be shifted closer towards the tail causing this overlap errorI'm suspecting that the compiler I am using GCC 13.3.0 may somehow emit code thats sized differently or it may have renamed some sections or some other compiler internal change may be the cause. I did try cross compiling as well as using binfmt to build it on various systems be it NixOS (for which im currently trying to package this) or dockercross.
Since I dind't find any information regarding a recommended compiler / binutils release I'm not entirely sure how recent my compiler can be. Esp as in https://github.com/ibm-s390-linux/s390-tools/blob/master/common.mak#L56 while only part of an example comment 4.8 is mentioned which was released 10 years ago.
The text was updated successfully, but these errors were encountered: