将 -pie 标志传递给 gcc 时堆栈溢出

发布于 2024-11-07 14:57:55 字数 1372 浏览 1 评论 0原文

我正在尝试将 fedora 移植到 mips cpu,一些软件包如“sudo”“krb5”,以下是通过配置自动添加“-fpie”“-pie”标志生成的“sudo”的 Makefile。

SUDO_LIBS =  -laudit -lselinux -lutil -lpam -ldl  -lldap   $(LIBS) $(NET_LIBS)
CFLAGS = -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2  -mabi=32 -march=mips3 -fpie
LDFLAGS = -L. -pie

当我尝试运行 sudo 时,发生核心转储。 gdb 中的调用框架 --core core.8420:

#0  0x2ad65bdc in elf_dynamic_do_rel (scope=<value optimized out>, reloc_mode=<value       optimized out>, consider_profiling=<value optimized out>)
at do-rel.h:120
#1  _dl_relocate_object (scope=<value optimized out>, reloc_mode=<value optimized out>, consider_profiling=<value optimized out>) at dl-reloc.c:268
#2  0x2ad5bd7c in dl_main (phdr=<value optimized out>, phnum=<value optimized out>, user_entry=<value optimized out>, auxv=<value optimized out>)
at rtld.c:2254
#3  0x2ad73744 in _dl_sysdep_start (start_argptr=<value optimized out>, dl_main=0x2ad5aa38 <dl_main>) at ../elf/dl-sysdep.c:244
#4  0x2ad58f08 in _dl_start_final (arg=0x7fc6d990, info=<value optimized out>) at rtld.c:334
#5  0x2ad590d8 in _dl_start (arg=0x7fc6d990) at rtld.c:562
#6  0x2ad588f8 in __start () from /lib/ld.so.1
Backtrace stopped: frame did not save the PC

当我删除 -pie ld 标志时,一切正常,这是因为 binutils 或 glibc 库加载器吗?

I'am trying to port fedora to mips cpu,some packages like "sudo" "krb5", following is the Makefile of "sudo" generated by configure which "-fpie" "-pie" flags was auto added.

SUDO_LIBS =  -laudit -lselinux -lutil -lpam -ldl  -lldap   $(LIBS) $(NET_LIBS)
CFLAGS = -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2  -mabi=32 -march=mips3 -fpie
LDFLAGS = -L. -pie

when i try run sudo , core dumped happen.
call frame in gdb --core core.8420:

#0  0x2ad65bdc in elf_dynamic_do_rel (scope=<value optimized out>, reloc_mode=<value       optimized out>, consider_profiling=<value optimized out>)
at do-rel.h:120
#1  _dl_relocate_object (scope=<value optimized out>, reloc_mode=<value optimized out>, consider_profiling=<value optimized out>) at dl-reloc.c:268
#2  0x2ad5bd7c in dl_main (phdr=<value optimized out>, phnum=<value optimized out>, user_entry=<value optimized out>, auxv=<value optimized out>)
at rtld.c:2254
#3  0x2ad73744 in _dl_sysdep_start (start_argptr=<value optimized out>, dl_main=0x2ad5aa38 <dl_main>) at ../elf/dl-sysdep.c:244
#4  0x2ad58f08 in _dl_start_final (arg=0x7fc6d990, info=<value optimized out>) at rtld.c:334
#5  0x2ad590d8 in _dl_start (arg=0x7fc6d990) at rtld.c:562
#6  0x2ad588f8 in __start () from /lib/ld.so.1
Backtrace stopped: frame did not save the PC

when i remove -pie ld flag, everything is ok, is this because of binutils of or glibc library loader?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

晨与橙与城 2024-11-14 14:57:55

这是 binutils 2.20 中的一个已知错误 - 它应该在新版本中修复。看
此 bugzilla 条目

This was a known bug in binutils 2.20 - it should be fixed in newer releases. See
this bugzilla entry.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文