소스 검색

elf-{fdpic, dsbt}.h: avoid void pointer's subtraction

elf-fdpic.h or elf-dsbt.h is included by link.h. When C++ program
includes <link.h>, we get following build failure.

../usr/include/bits/elf-fdpic.h: In function 'void* __reloc_pointer(void*, const elf32_fdpic_loadmap*)':
../usr/include/bits/elf-fdpic.h:95: error: invalid use of 'void'

void pointer addition and subtraction is not allowed in C++ as it has
undetermined size, however in C with language extension it is possible
because sizeof void is treated as one byte.

Instead of performing subtraction on void pointers, typecast it to char*
first.

This build failure is detected by Buildroot autobuilder.
http://autobuild.buildroot.net/results/a10/a10ed48e6eb8411a3d8372f57c05fd11130da0e0/

Signed-off-by: Rahul Bedarkar <rahul.bedarkar@imgtec.com>
Rahul Bedarkar 9 년 전
부모
커밋
2c24209237
3개의 변경된 파일3개의 추가작업 그리고 3개의 파일을 삭제
  1. 1 1
      libc/sysdeps/linux/bfin/bits/elf-fdpic.h
  2. 1 1
      libc/sysdeps/linux/c6x/bits/elf-dsbt.h
  3. 1 1
      libc/sysdeps/linux/frv/bits/elf-fdpic.h

+ 1 - 1
libc/sysdeps/linux/bfin/bits/elf-fdpic.h

@@ -91,7 +91,7 @@ __reloc_pointer (void *p,
       /* This should be computed as part of the pointer comparison
 	 above, but we want to use the carry in the comparison, so we
 	 can't convert it to an integer type beforehand.  */
-      unsigned long offset = p - (void*)map->segs[c].p_vaddr;
+      unsigned long offset = (char*)p - (char*)map->segs[c].p_vaddr;
       /* We only check for one-past-the-end for the last segment,
 	 assumed to be the data segment, because other cases are
 	 ambiguous in the absence of padding between segments, and

+ 1 - 1
libc/sysdeps/linux/c6x/bits/elf-dsbt.h

@@ -94,7 +94,7 @@ __reloc_pointer (void *p,
 
   for (c = 0; c < map->nsegs; c++)
     {
-      unsigned long offset = p - (void*)map->segs[c].p_vaddr;
+      unsigned long offset = (char*)p - (char*)map->segs[c].p_vaddr;
       /* We only check for one-past-the-end for the second segment,
 	 assumed to be the data segment, because other cases are
 	 ambiguous in the absence of padding between segments, and

+ 1 - 1
libc/sysdeps/linux/frv/bits/elf-fdpic.h

@@ -91,7 +91,7 @@ __reloc_pointer (void *p,
       /* This should be computed as part of the pointer comparison
 	 above, but we want to use the carry in the comparison, so we
 	 can't convert it to an integer type beforehand.  */
-      unsigned long offset = p - (void*)map->segs[c].p_vaddr;
+      unsigned long offset = (char*)p - (char*)map->segs[c].p_vaddr;
       /* We only check for one-past-the-end for the last segment,
 	 assumed to be the data segment, because other cases are
 	 ambiguous in the absence of padding between segments, and