Skip to content

Adding -m32 option to gcc under Linux#10

Open
Saldef wants to merge 1 commit intopacman128:masterfrom
Saldef:Adding-`-m32`-option-to-gcc-under-Linux
Open

Adding -m32 option to gcc under Linux#10
Saldef wants to merge 1 commit intopacman128:masterfrom
Saldef:Adding-`-m32`-option-to-gcc-under-Linux

Conversation

@Saldef
Copy link
Copy Markdown

@Saldef Saldef commented Apr 10, 2023

1- It will not successfully compile under 64-bit architecture if the -m32 is not added. I guess (not sure though) the reason is a change in GCC where they are no longer allowing 32-bit absolute addressing on Linux x86_64. Also, One needs to install gcc-multilib and g++-multilib packages before-head, because the 32-bit version of libgcc isn't available on the 64-bit gcc. This might also need to be added in the LaTex version of book, sections 1.4.4 and 1.4.5

2- One more thing, assembling the asm_io.asm was not mentioned in section 1.4.3, although it is necessary, and it has a caveat where one needs to add the inline macro -d ELF_TYPE, this would only be noticed when reading the comments of the asm_io.asm file. For a beginner, and for his/her first code. this will hinder a bit, and distract the learner on a quest on the web trying to find a solutions.

1- It will not successfully compile under 64-bit architecture if the `-m32` is not added. I guess (not sure though) the reason is a change in GCC where they [no longer allowed 32-bit absolute addressing](https://stackoverflow.com/questions/43367427/32-bit-absolute-addresses-no-longer-allowed-in-x86-64-linux#) on Linux x86_64. Also, One needs to install `gcc-multilib` and `g++-multilib` packages before-head, because the 32-bit version of libgcc [isn't available on the 64-bit gcc](https://stackoverflow.com/questions/34219248/usr-bin-ld-cannot-find-lgcc-error-in-the-linkage-of-assembly). This might also need to be added in the LaTex version of book, sections 1.4.4 and  1.4.5 

2- One more thing, assembling the `asm_io.asm` was not mentioned in section 1.4.3, although it is necessary, and it has a caveat where one needs to add the inline macro `-d ELF_TYPE`, this would only be noticed when reading the comments of the `asm_io.asm` file. For a beginner, and for his/her first code. this will hinder a bit, and distract the learner on a quest on the web trying to find a solutions.
@pacman128
Copy link
Copy Markdown
Owner

Thanks for your pull request, but this is not the correct fix (or at least an incomplete one). There's a Linux Makefile that builds everything (with the -m32 flag). That is probably what needs to be documented. You're right that it would be a good idea to specify how to set up the 32-bit environment on a 64-bit system.

The Makefile will also build the asm_io object file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants