[go: nahoru, domu]

Skip to content
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

add -fno-PIC flag in Makefile. #22

Merged
merged 1 commit into from
Feb 28, 2019

Conversation

Csomnia
Copy link
@Csomnia Csomnia commented Jul 19, 2017

When I compile with newer version gcc, I find that the code is position-indepent, it makes kernel can't work properly in qemu. To solve this, add -fno-PIC in Makefile force gcc to generate absolute code.

@chyyuu
Copy link
Owner
chyyuu commented Mar 8, 2018

Thank you!
But I can compile&run labs without -fno-PIC flag in Makefile in ubuntu 16.04/17.10 x86-64.

@chyyuu chyyuu closed this Mar 8, 2018
@twd2
Copy link
twd2 commented Mar 10, 2018

Some of my classmates do have this problem...

@FluorineDog
Copy link
FluorineDog commented May 8, 2018

I have encoutered this problem. I tested gcc6.4.1 and gcc7+ with -Q -v flags, and found that -fPIC is a default option for gcc7+, while gcc6- DOES NOT set it to default.
It's quite annoying to find ucore not working with the newer gcc. Please fix it, for others does not happend to read this pull request. @chyyuu

@twd2
Copy link
twd2 commented Feb 26, 2019

ping

@Harry-Chen
Copy link

禁用位置无关代码也有助于减小代码体积。如果不开启的话,在较新版本的 gcc 中,bootloader 的体积很容易就会超过 512 字节导致无法生成扇区

@twd2
Copy link
twd2 commented Feb 28, 2019

Conclusions:

  1. -fPIC is enabled by default in newer versions (>=7) of GCC.
  2. -fPIC can produce some relocation-related sections, which ucore's bootloader cannot process correctly.
  3. In addition, -fPIC may increase the code size significantly, making bootloader code larger than 512B.
  4. -fno-PIC -fno-PIE is the easiest way to solve above problems without changing a lot of code.
  5. Thus, -fno-PIC -fno-PIE is needed.

@chyyuu chyyuu reopened this Feb 28, 2019
@chyyuu chyyuu merged commit 03e4c47 into chyyuu:master Feb 28, 2019
@chyyuu
Copy link
Owner
chyyuu commented Feb 28, 2019

@Csomnia Thank you! I merged your PR.

@Csomnia Csomnia deleted the fix-newer-gcc-compile-PIC branch March 12, 2019 06:32
chyyuu pushed a commit that referenced this pull request Jun 29, 2020
chyyuu pushed a commit that referenced this pull request Jun 29, 2020
目前问题:内核线程栈上切页表会崩;用户线程 2M 堆栈时中间有一个页无法访问
chyyuu pushed a commit that referenced this pull request Jun 29, 2020
hello_world 如果最后是 loop{} 运行一段时间后会玄学挂掉
chyyuu pushed a commit that referenced this pull request Jun 29, 2020
chyyuu pushed a commit that referenced this pull request Jun 29, 2020
Resolve "lab6"

Closes #22

See merge request os20-rcore-tutorial/rcore-tutorial!18
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.

5 participants