* Josef Wolf: > Strictly speaking, the symbols defined by the linker (_sidata, _sdata, _edata, > _sbss and _ebss) are unrelated when seen from the perspective of the > compiler. Therefore, it is not allowed by the standard to use their addresses > for comparison. > > So what would be the proper way to pass this information from the linker to the > compiler? In glibc, we use this: /* Perform vtable pointer validation. If validation fails, terminate the process. */ static inline const struct _IO_jump_t * IO_validate_vtable (const struct _IO_jump_t *vtable) { /* Fast path: The vtable pointer is within the __libc_IO_vtables section. */ uintptr_t section_length = __stop___libc_IO_vtables - __start___libc_IO_vtables; uintptr_t ptr = (uintptr_t) vtable; uintptr_t offset = ptr - (uintptr_t) __start___libc_IO_vtables; if (__glibc_unlikely (offset >= section_length)) /* The vtable pointer is not in the expected section. Use the slow path, which will terminate the process if necessary. */ _IO_vtable_check (); return vtable; } I do not know how effective this is. In C++, you can use std::less, which was enhanced to cover your use case. Thanks, Florian