[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug ld/28695] New: Linker doesn't warn p_align < sh_sh_addralign
From: |
hjl.tools at gmail dot com |
Subject: |
[Bug ld/28695] New: Linker doesn't warn p_align < sh_sh_addralign |
Date: |
Tue, 14 Dec 2021 14:22:05 +0000 |
https://sourceware.org/bugzilla/show_bug.cgi?id=28695
Bug ID: 28695
Summary: Linker doesn't warn p_align < sh_sh_addralign
Product: binutils
Version: 2.38 (HEAD)
Status: NEW
Severity: normal
Priority: P2
Component: ld
Assignee: unassigned at sourceware dot org
Reporter: hjl.tools at gmail dot com
Target Milestone: ---
[hjl@gnu-cfl-2 align-1]$ cat load.c
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#define ALIGN 0x200000
int
__attribute__ ((weak))
is_aligned (void *p, int align)
{
return (((uintptr_t) p) & (align - 1)) != 0;
}
int foo __attribute__ ((aligned (ALIGN))) = 1;
int
main (void)
{
printf ("foo: %p\n", &foo);
if (is_aligned (&foo, ALIGN))
abort ();
return 0;
}
[hjl@gnu-cfl-2 align-1]$ make
gcc -O2 -fPIE -c -o load.o load.c
gcc -pie -Wl,-z,max-page-size=0x1000 -O2 -fPIE -o pie load.o
readelf -SW load.o | grep "\.data"
[ 2] .data PROGBITS 0000000000000000 200000 000004 00 WA
0 0 2097152
readelf -lW pie | grep LOAD
LOAD 0x000000 0x0000000000000000 0x0000000000000000 0x0006a8
0x0006a8 R 0x1000
LOAD 0x001000 0x0000000000001000 0x0000000000001000 0x0001bd
0x0001bd R E 0x1000
LOAD 0x002000 0x0000000000002000 0x0000000000002000 0x00010c
0x00010c R 0x1000
LOAD 0x002de0 0x0000000000003de0 0x0000000000003de0 0x000248
0x000248 RW 0x1000
LOAD 0x200000 0x0000000000200000 0x0000000000200000 0x200004
0x200008 RW 0x1000
./pie
foo: 0x7f9fcb0fa000
make: *** [Makefile:9: all] Aborted (core dumped)
[hjl@gnu-cfl-2 align-1]$
--
You are receiving this mail because:
You are on the CC list for the bug.
- [Bug ld/28695] New: Linker doesn't warn p_align < sh_sh_addralign,
hjl.tools at gmail dot com <=